codeShare commited on
Commit
cd41de5
·
verified ·
1 Parent(s): 24d5dba

Upload YT-playlist-to-mp3.ipynb

Browse files
Files changed (1) hide show
  1. YT-playlist-to-mp3.ipynb +1 -108
YT-playlist-to-mp3.ipynb CHANGED
@@ -1,108 +1 @@
1
- {
2
- "nbformat": 4,
3
- "nbformat_minor": 0,
4
- "metadata": {
5
- "colab": {
6
- "provenance": [
7
- {
8
- "file_id": "https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb",
9
- "timestamp": 1725365086834
10
- }
11
- ]
12
- },
13
- "kernelspec": {
14
- "name": "python3",
15
- "display_name": "Python 3"
16
- },
17
- "language_info": {
18
- "name": "python"
19
- }
20
- },
21
- "cells": [
22
- {
23
- "cell_type": "markdown",
24
- "source": [
25
- "This Notebook will take a Youtube Playlist and convert all videos to MP3:s , which will be stored on a folder on your Google Drive."
26
- ],
27
- "metadata": {
28
- "id": "I64oSgGJxki5"
29
- }
30
- },
31
- {
32
- "cell_type": "code",
33
- "execution_count": null,
34
- "metadata": {
35
- "id": "KXsmL_npl5Zf"
36
- },
37
- "outputs": [],
38
- "source": [
39
- "#Initialize\n",
40
- "import os\n",
41
- "def my_mkdirs(folder):\n",
42
- " if os.path.exists(folder)==False:\n",
43
- " os.makedirs(folder)\n",
44
- "my_mkdirs('/content/tmp/')"
45
- ]
46
- },
47
- {
48
- "cell_type": "code",
49
- "source": [
50
- "#Reinstall youtube_dl because the version on Colab is outdated\n",
51
- "!python3 -m pip install --force-reinstall https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz\n",
52
- "import yt_dlp as youtube_dl\n"
53
- ],
54
- "metadata": {
55
- "id": "CT8O2CJYl-Cb"
56
- },
57
- "execution_count": null,
58
- "outputs": []
59
- },
60
- {
61
- "cell_type": "code",
62
- "source": [
63
- "#Mount Google Drive\n",
64
- "from google.colab import drive\n",
65
- "drive.mount('/content/drive')"
66
- ],
67
- "metadata": {
68
- "id": "vxae5FCml-0A"
69
- },
70
- "execution_count": null,
71
- "outputs": []
72
- },
73
- {
74
- "cell_type": "code",
75
- "source": [
76
- "\n",
77
- "playlist_URL = '' # @param {type:'string'}\n",
78
- "playlist_start = 1 # @param {type:'number'}\n",
79
- "playlist_end = 9999 # @param {type:'number'}\n",
80
- "\n",
81
- "#Extract all videos in YT playlist mp3 files\n",
82
- "#Aborting this code is fine if list is latge ( You will keep downloaded mp3:s)\n",
83
- "%cd /content/tmp\n",
84
- "!yt-dlp --playlist-end {playlist_end} --playlist-start {playlist_start} --extract-audio --audio-format mp3 -o \"%(title)s.%(ext)s\" {playlist_URL}"
85
- ],
86
- "metadata": {
87
- "id": "0K9n3HM6l-7x"
88
- },
89
- "execution_count": null,
90
- "outputs": []
91
- },
92
- {
93
- "cell_type": "code",
94
- "source": [
95
- "\n",
96
- "drive_folder_name = 'AudiosP1' # @param {type:'string'}\n",
97
- "\n",
98
- "%cd /content/\n",
99
- "!zip -r /content/drive/MyDrive/{drive_folder_name}.zip /content/tmp"
100
- ],
101
- "metadata": {
102
- "id": "D04FssOTma-2"
103
- },
104
- "execution_count": null,
105
- "outputs": []
106
- }
107
- ]
108
- }
 
1
+ {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1736477078136},{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1725365086834}]},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":["This Notebook will take a Youtube Playlist and convert all videos to MP3:s , which will be stored on a folder on your Google Drive."],"metadata":{"id":"I64oSgGJxki5"}},{"cell_type":"code","execution_count":null,"metadata":{"id":"KXsmL_npl5Zf"},"outputs":[],"source":["#Initialize\n","import os\n","def my_mkdirs(folder):\n"," if os.path.exists(folder)==False:\n"," os.makedirs(folder)\n","my_mkdirs('/content/tmp/')"]},{"cell_type":"code","source":["#NOTE: you need to download cookies from youtube to your drive folder because of recent Youtubr BS restrictions\n","#Reinstall youtube_dl because the version on Colab is outdated\n","!python3 -m pip install --force-reinstall https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz\n","import yt_dlp as youtube_dl\n"],"metadata":{"id":"CT8O2CJYl-Cb"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["#Mount Google Drive\n","from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"id":"vxae5FCml-0A"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["\n","playlist_URL = '' # @param {type:'string'}\n","playlist_start = 1 # @param {type:'number'}\n","playlist_end = 9999 # @param {type:'number'}\n","\n","#Extract all videos in YT playlist mp3 files\n","#Aborting this code is fine if list is latge ( You will keep downloaded mp3:s)\n","%cd /content/tmp\n","!yt-dlp --cookies /content/drive/MyDrive/ytcookies.txt --playlist-end {playlist_end} --playlist-start {playlist_start} --extract-audio --audio-format mp3 -o \"%(title)s.%(ext)s\" {playlist_URL}"],"metadata":{"id":"0K9n3HM6l-7x"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["\n","drive_folder_name = 'AudiosP1' # @param {type:'string'}\n","\n","%cd /content/\n","!zip -r /content/drive/MyDrive/{drive_folder_name}.zip /content/tmp"],"metadata":{"id":"D04FssOTma-2"},"execution_count":null,"outputs":[]}]}