File size: 1,193 Bytes
9253faf
1
2
{"cells":[{"cell_type":"code","execution_count":6,"metadata":{"executionInfo":{"elapsed":148,"status":"ok","timestamp":1703035908850,"user":{"displayName":"Manuel Lara","userId":"10182117638611832193"},"user_tz":360},"id":"w3t4qHlYyIPE"},"outputs":[],"source":["import re\n","import pandas as pd\n","\n","fname = \"transcript_GZTr1-Gp74U.txt\"\n","v = fname.split(\"_\")[1].split(\".\")[0]\n","lines = open(fname).readlines()\n","link = f\"v={v}&ab_channel=RoaringKitty\"\n","results = []\n","row = {}\n","for i, line in enumerate(lines):\n","    if re.match(r\"\\d+:\\d+\", line):\n","        row[\"Time\"] = line\n","        if i > 0:\n","            row[\"Link\"] = link\n","            results.append(row)\n","        row = {}\n","    else:\n","        row[\"Text\"] = line\n","df = pd.DataFrame(results)\n","df.to_csv(\"transcript.csv\")"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"1U0TqJUwyM4R"},"outputs":[],"source":["https://www.youtube.com/watch?"]}],"metadata":{"colab":{"authorship_tag":"ABX9TyOSs3ocpSBDJmGfEvS/JTCv","provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"name":"python"}},"nbformat":4,"nbformat_minor":0}