Delete dl_Youtube_playlist.ipynb
Browse files- dl_Youtube_playlist.ipynb +0 -133
dl_Youtube_playlist.ipynb
DELETED
|
@@ -1,133 +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://www.youtube.com/embed/....',\n",
|
| 63 |
-
"'https://www.youtube.com/embed/....']"
|
| 64 |
-
],
|
| 65 |
-
"metadata": {
|
| 66 |
-
"id": "YHqAThDCRj4C"
|
| 67 |
-
},
|
| 68 |
-
"execution_count": 2,
|
| 69 |
-
"outputs": []
|
| 70 |
-
},
|
| 71 |
-
{
|
| 72 |
-
"cell_type": "code",
|
| 73 |
-
"metadata": {
|
| 74 |
-
"id": "W7bW6g_AwxfX"
|
| 75 |
-
},
|
| 76 |
-
"source": [
|
| 77 |
-
"#Download all the youtube videos as .M4A files\n",
|
| 78 |
-
"%cd /content/tmp\n",
|
| 79 |
-
"for ind,url in enumerate(urls):\n",
|
| 80 |
-
" !yt-dlp $url -f 'bestaudio[ext=m4a]' -o '%(title)s.m4a'"
|
| 81 |
-
],
|
| 82 |
-
"execution_count": null,
|
| 83 |
-
"outputs": []
|
| 84 |
-
},
|
| 85 |
-
{
|
| 86 |
-
"cell_type": "code",
|
| 87 |
-
"source": [
|
| 88 |
-
"#Convert all M4A files to MP3 (NOTE: Make sure to rename M4A files that contain parenthesis () in their name first!) \n",
|
| 89 |
-
"output_folder = '/content/AudiosP1/'\n",
|
| 90 |
-
"my_mkdirs(output_folder)\n",
|
| 91 |
-
"import glob\n",
|
| 92 |
-
"files = glob.glob('/content/tmp/*')\n",
|
| 93 |
-
"for file in files:\n",
|
| 94 |
-
" out_file = f'{output_folder}{file[13:-3]}mp3'\n",
|
| 95 |
-
" file = file.replace(' ','\\ ')\n",
|
| 96 |
-
" out_file = out_file.replace(' ','\\ ')\n",
|
| 97 |
-
" !ffmpeg -i $file -vn -ab 384k -ar 44100 -y $out_file\n"
|
| 98 |
-
],
|
| 99 |
-
"metadata": {
|
| 100 |
-
"id": "48htqMULSrBz"
|
| 101 |
-
},
|
| 102 |
-
"execution_count": null,
|
| 103 |
-
"outputs": []
|
| 104 |
-
},
|
| 105 |
-
{
|
| 106 |
-
"cell_type": "code",
|
| 107 |
-
"source": [
|
| 108 |
-
"#Zip the folder and store it on Google Drive\n",
|
| 109 |
-
"%cd /content/\n",
|
| 110 |
-
"!zip -r /content/drive/MyDrive/AudiosP1.zip /content/AudiosP1"
|
| 111 |
-
],
|
| 112 |
-
"metadata": {
|
| 113 |
-
"id": "BoNaY4v6S2UA"
|
| 114 |
-
},
|
| 115 |
-
"execution_count": null,
|
| 116 |
-
"outputs": []
|
| 117 |
-
},
|
| 118 |
-
{
|
| 119 |
-
"cell_type": "code",
|
| 120 |
-
"source": [
|
| 121 |
-
"#Delete the folder (as a safeguard, this will not work unless you manually change the name of the folder first)\n",
|
| 122 |
-
"%cd /content/\n",
|
| 123 |
-
"import shutil\n",
|
| 124 |
-
"shutil.rmtree(\"/content/xxx-AudiosP1\")"
|
| 125 |
-
],
|
| 126 |
-
"metadata": {
|
| 127 |
-
"id": "agjq4INSU0x2"
|
| 128 |
-
},
|
| 129 |
-
"execution_count": null,
|
| 130 |
-
"outputs": []
|
| 131 |
-
}
|
| 132 |
-
]
|
| 133 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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