codeShare commited on
Commit
3d8b836
1 Parent(s): dde9747

Update YT-playlist-to-mp3.ipynb

Browse files
Files changed (1) hide show
  1. YT-playlist-to-mp3.ipynb +106 -1
YT-playlist-to-mp3.ipynb CHANGED
@@ -1 +1,106 @@
1
- {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyN6NfCZQToBwEXefzESrzlD"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"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":["#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","\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 --extract-audio --audio-format mp3 -o \"%(title)s.%(ext)s\" {playlist_URL}"],"metadata":{"id":"0K9n3HM6l-7x"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["%cd /content/\n","drive-folder-name = 'AudiosP1' # @param {type:'string'}","!zip -r /content/drive/MyDrive/{drive-folder-name}.zip /content/tmp"],"metadata":{"id":"D04FssOTma-2"},"execution_count":null,"outputs":[]}]}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "\n",
79
+ "#Extract all videos in YT playlist mp3 files\n",
80
+ "#Aborting this code is fine if list is latge ( You will keep downloaded mp3:s)\n",
81
+ "%cd /content/tmp\n",
82
+ "!yt-dlp --extract-audio --audio-format mp3 -o \"%(title)s.%(ext)s\" {playlist_URL}"
83
+ ],
84
+ "metadata": {
85
+ "id": "0K9n3HM6l-7x"
86
+ },
87
+ "execution_count": null,
88
+ "outputs": []
89
+ },
90
+ {
91
+ "cell_type": "code",
92
+ "source": [
93
+ "\n",
94
+ "drive-folder-name = 'AudiosP1' # @param {type:'string'}\n",
95
+ "\n",
96
+ "%cd /content/\n",
97
+ "!zip -r /content/drive/MyDrive/{drive-folder-name}.zip /content/tmp"
98
+ ],
99
+ "metadata": {
100
+ "id": "D04FssOTma-2"
101
+ },
102
+ "execution_count": null,
103
+ "outputs": []
104
+ }
105
+ ]
106
+ }