Delete tmp.ipynb
Browse files
tmp.ipynb
DELETED
@@ -1,137 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"nbformat": 4,
|
3 |
-
"nbformat_minor": 0,
|
4 |
-
"metadata": {
|
5 |
-
"colab": {
|
6 |
-
"provenance": []
|
7 |
-
},
|
8 |
-
"kernelspec": {
|
9 |
-
"name": "python3",
|
10 |
-
"display_name": "Python 3"
|
11 |
-
}
|
12 |
-
},
|
13 |
-
"cells": [
|
14 |
-
{
|
15 |
-
"cell_type": "markdown",
|
16 |
-
"metadata": {
|
17 |
-
"id": "view-in-github"
|
18 |
-
},
|
19 |
-
"source": [
|
20 |
-
"<a href=\"https://colab.research.google.com/github/ryanwebster90/colab-yt-dl/blob/main/dl_yt_playlist.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
21 |
-
]
|
22 |
-
},
|
23 |
-
{
|
24 |
-
"cell_type": "markdown",
|
25 |
-
"source": [
|
26 |
-
"1) Youtube playlist link extractor : https://technmind.com/youtube-playlist-link-extractor/\n",
|
27 |
-
"\n",
|
28 |
-
"2) Extract Links from text : https://www.browserling.com/tools/extract-urls"
|
29 |
-
],
|
30 |
-
"metadata": {
|
31 |
-
"id": "vkCFp3XVxq48"
|
32 |
-
}
|
33 |
-
},
|
34 |
-
{
|
35 |
-
"cell_type": "code",
|
36 |
-
"source": [
|
37 |
-
"#Initialize\n",
|
38 |
-
"import os\n",
|
39 |
-
"def my_mkdirs(folder):\n",
|
40 |
-
" if os.path.exists(folder)==False:\n",
|
41 |
-
" os.makedirs(folder)\n",
|
42 |
-
"my_mkdirs('/content/tmp/')\n",
|
43 |
-
"\n",
|
44 |
-
"#Reinstall youtube_dl because the version on Colab is outdated\n",
|
45 |
-
"!python3 -m pip install --force-reinstall https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz\n",
|
46 |
-
"import yt_dlp as youtube_dl\n",
|
47 |
-
"\n",
|
48 |
-
"#Mount Google Drive\n",
|
49 |
-
"from google.colab import drive\n",
|
50 |
-
"drive.mount('/content/drive')"
|
51 |
-
],
|
52 |
-
"metadata": {
|
53 |
-
"id": "1YSLwB9ex9HR"
|
54 |
-
},
|
55 |
-
"execution_count": null,
|
56 |
-
"outputs": []
|
57 |
-
},
|
58 |
-
{
|
59 |
-
"cell_type": "code",
|
60 |
-
"source": [
|
61 |
-
"#Enter the \"share\" links to the youtube videos here\n",
|
62 |
-
"urls = ['https://youtu.be/9oe09y7xOZc?si=wASGp2U4UV3bGl15',
|
63 |
-
'https://youtu.be/VoJv0JaPVXI?si=RcpuHno8kJgf9dTo',
|
64 |
-
'https://youtu.be/unYiAcOxsPg?si=UgIZxZZCgu3-m6df',
|
65 |
-
'https://youtu.be/MW7cqranFy8?si=ay6kaFGmz1OnLO7a',
|
66 |
-
'https://youtu.be/otuRpsrDN9I?si=nltiEnVZBXU67xFQ',
|
67 |
-
'https://youtu.be/HUCLGMKYI-U?si=VCP0D0v4AvO3xB04']"
|
68 |
-
],
|
69 |
-
"metadata": {
|
70 |
-
"id": "YHqAThDCRj4C"
|
71 |
-
},
|
72 |
-
"execution_count": 2,
|
73 |
-
"outputs": []
|
74 |
-
},
|
75 |
-
{
|
76 |
-
"cell_type": "code",
|
77 |
-
"metadata": {
|
78 |
-
"id": "W7bW6g_AwxfX"
|
79 |
-
},
|
80 |
-
"source": [
|
81 |
-
"#Download all the youtube videos as .M4A files\n",
|
82 |
-
"%cd /content/tmp\n",
|
83 |
-
"for ind,url in enumerate(urls):\n",
|
84 |
-
" !yt-dlp $url -f 'bestaudio[ext=m4a]' -o '%(title)s.m4a'"
|
85 |
-
],
|
86 |
-
"execution_count": null,
|
87 |
-
"outputs": []
|
88 |
-
},
|
89 |
-
{
|
90 |
-
"cell_type": "code",
|
91 |
-
"source": [
|
92 |
-
"#Convert all M4A files to MP3 (NOTE: Make sure to rename M4A files that contain parenthesis () in their name first!) \n",
|
93 |
-
"output_folder = '/content/AudiosP1/'\n",
|
94 |
-
"my_mkdirs(output_folder)\n",
|
95 |
-
"import glob\n",
|
96 |
-
"files = glob.glob('/content/tmp/*')\n",
|
97 |
-
"for file in files:\n",
|
98 |
-
" out_file = f'{output_folder}{file[13:-3]}mp3'\n",
|
99 |
-
" file = file.replace(' ','\\ ')\n",
|
100 |
-
" out_file = out_file.replace(' ','\\ ')\n",
|
101 |
-
" !ffmpeg -i $file -vn -ab 384k -ar 44100 -y $out_file\n"
|
102 |
-
],
|
103 |
-
"metadata": {
|
104 |
-
"id": "48htqMULSrBz"
|
105 |
-
},
|
106 |
-
"execution_count": null,
|
107 |
-
"outputs": []
|
108 |
-
},
|
109 |
-
{
|
110 |
-
"cell_type": "code",
|
111 |
-
"source": [
|
112 |
-
"#Zip the folder and store it on Google Drive\n",
|
113 |
-
"%cd /content/\n",
|
114 |
-
"!zip -r /content/drive/MyDrive/AudiosP1.zip /content/AudiosP1"
|
115 |
-
],
|
116 |
-
"metadata": {
|
117 |
-
"id": "BoNaY4v6S2UA"
|
118 |
-
},
|
119 |
-
"execution_count": null,
|
120 |
-
"outputs": []
|
121 |
-
},
|
122 |
-
{
|
123 |
-
"cell_type": "code",
|
124 |
-
"source": [
|
125 |
-
"#Delete the folder (as a safeguard, this will not work unless you manually change the name of the folder first)\n",
|
126 |
-
"%cd /content/\n",
|
127 |
-
"import shutil\n",
|
128 |
-
"shutil.rmtree(\"/content/xxx-AudiosP1\")"
|
129 |
-
],
|
130 |
-
"metadata": {
|
131 |
-
"id": "agjq4INSU0x2"
|
132 |
-
},
|
133 |
-
"execution_count": null,
|
134 |
-
"outputs": []
|
135 |
-
}
|
136 |
-
]
|
137 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|