Compare commits

..

3 Commits

Author SHA1 Message Date
5c32daf593 Change order of arguments 2024-04-28 16:28:32 +02:00
15f332d318 Updated list of songs 2024-04-28 16:19:46 +02:00
2754ebd482 Add .pre-commit 2024-04-28 16:18:59 +02:00
3 changed files with 283 additions and 206 deletions

17
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.2
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format

View File

@@ -41,7 +41,7 @@
41 - House Empire - Excuse Me (Break Beat Mix) 41 - House Empire - Excuse Me (Break Beat Mix)
42 - Let's Get Loco 42 - Let's Get Loco
43 - Death Race 43 - Death Race
44 - Energy 52 - Café Del Mar (Mike Reitmayer Remix) 44 - Mike Reitmayer - Café Del Mar 2002
45 - 2 Funky in Here (Maceo Rivas & Dr Black Sheep Remix) 45 - 2 Funky in Here (Maceo Rivas & Dr Black Sheep Remix)
46 - Novy vs Eniac Smoke Dis (Original Mix) [Breakbeat] 46 - Novy vs Eniac Smoke Dis (Original Mix) [Breakbeat]
47 - X-Perimental II 47 - X-Perimental II
@@ -58,161 +58,216 @@
58 - Milk Inc. - Vache (Remix Dj Fen) 58 - Milk Inc. - Vache (Remix Dj Fen)
59 - EMERGENCY - CHECK IT OUT (DJ GAZ BREAKBEAT MIX) 59 - EMERGENCY - CHECK IT OUT (DJ GAZ BREAKBEAT MIX)
60 - Law of Life 60 - Law of Life
61 - Infiniti (Scott Christina) - Running Away (Lords Of Motion 2K24 Remix) 61 - Welcome To The Rave
62 - Welcome To The Rave 62 - Geon - Intensity (Kulman Remix)
63 - Geon - Intensity (Kulman Remix) 63 - Easy (Extended Mix)
64 - Easy (Extended Mix) 64 - Mr Fli - Under The Sky (Original Version)
65 - Mr Fli - Under The Sky (Original Version) 65 - Heartjumpa (Original Version)
66 - Heartjumpa (Original Version) 66 - Southside Spinners - Luvstruck (Breakbeat Remix)
67 - Southside Spinners - Luvstruck (Breakbeat Remix) 67 - Your Caress (All I Need) (Extended Mix)
68 - Your Caress (All I Need) (Extended Mix) 68 - Urban Hype - A Trip To Trumpton (12'' Club Version) (1992)
69 - Urban Hype - A Trip To Trumpton (12'' Club Version) (1992) 69 - Dj Voyce - La Musica
70 - Dj Voyce - La Musica 70 - Benigno
71 - Benigno 71 - Hyper Go
72 - Hyper Go 72 - Backdraft - Headcharge
73 - Backdraft - Headcharge 73 - DJ Zinc and Jammin Go DJ (Original Mix)
74 - DJ Zinc and Jammin Go DJ (Original Mix) 74 - Punk Or Funk (Original Mix)
75 - Punk Or Funk (Original Mix) 75 - Morpheus (Original Mix)
76 - Morpheus (Original Mix) 76 - Baddest DJ (Original Mix)
77 - Baddest DJ (Original Mix) 77 - Dj Fen - To The World (Kultür Remix)
78 - Dj Fen - To The World (Kultür Remix) 78 - DJ Nomad & Taranto - Horizon (Original Mix Edit) @breakbeatologia @Adolfoyadore
79 - DJ Nomad & Taranto - Horizon (Original Mix Edit) @breakbeatologia @Adolfoyadore 79 - Con - Let It Go (Break-Trance Mix)
80 - Con - Let It Go (Break-Trance Mix) 80 - Before - Believe In Love (Break Beat Mix)
81 - Before - Believe In Love (Break Beat Mix) 81 - Capella - U Got 2 Know (Kultür + Jan-B Break Remix)
82 - Capella - U Got 2 Know (Kultür + Jan-B Break Remix) 82 - Warning
83 - Warning 83 - What Ya Say
84 - What Ya Say 84 - Sol Brothers - That Elvis Track (DC Remix)
85 - Sol Brothers - That Elvis Track (DC Remix) 85 - Propellerheads Dive! (Original Mix)
86 - Propellerheads Dive! (Original Mix) 86 - Progression - Reach Further (Original MIx)
87 - Progression - Reach Further (Original MIx) 87 - O-Men - The Omen (Original Mix)
88 - O-Men - The Omen (Original Mix) 88 - Dj Kultur - Magic
89 - Dj Kultur - Magic 89 - Yves Deruyter - Outsiders (Marusha Remix)
90 - Yves Deruyter - Outsiders (Marusha Remix) 90 - Six Million
91 - Six Million 91 - JDS Blackout
92 - JDS Blackout 92 - Zero - Emit/Collect (Rennie Pilgrem Agatha Stomp)
93 - Zero - Emit/Collect (Rennie Pilgrem Agatha Stomp) 93 - 777 (Remastered Lucky Strike Mix)
94 - 777 (Remastered Lucky Strike Mix) 94 - It's Ruff
95 - It's Ruff 95 - To The Top
96 - To The Top 96 - Manic Stamped
97 - Manic Stamped 97 - Elite Force - Bombin The Subway (Elite Force Monsta Mix)
98 - Elite Force - Bombin The Subway (Elite Force Monsta Mix) 98 - Take Me 2003
99 - Take Me 2003 99 - Dj Quest - Wormhole (feat Odissi)
100 - Dj Quest - Wormhole (feat Odissi) 100 - Cut and Run - Murder in the jamrock (Tclub)
101 - Cut and Run - Murder in the jamrock (Tclub) 101 - Distortionz vs Deep Impact - Demonz - Bass Invaderz - Breakbeat, Nuskool Breaks
102 - Distortionz vs Deep Impact - Demonz - Bass Invaderz - Breakbeat, Nuskool Breaks 102 - Citriq Lines - Reset
103 - Citriq Lines - Reset 103 - Private video
104 - Private video 104 - New Dimension
105 - New Dimension 105 - Deep Impact - Carpet Muncha (Original Mix)
106 - Deep Impact - Carpet Muncha (Original Mix) 106 - DJ QUEST gravelmuncha
107 - DJ QUEST gravelmuncha 107 - Kung Fu Funk (Original Mix)
108 - Kung Fu Funk (Original Mix) 108 - Pendulum - Fasten Your Seltbelt Feat. The Freestylers
109 - Pendulum - Fasten Your Seltbelt Feat. The Freestylers 109 - ED209 - Infectious (Distortionz Remix) - Hardcore Beats - Breakbeat, Nuskool Breaks
110 - ED209 - Infectious (Distortionz Remix) - Hardcore Beats - Breakbeat, Nuskool Breaks 110 - Cut & Run No Good
111 - Cut & Run No Good 111 - DJs Friction And Spice Groove Me (Original)
112 - DJs Friction And Spice Groove Me (Original) 112 - Fall Into Me (DJ Icey Remix)
113 - Fall Into Me (DJ Icey Remix) 113 - Interstellar
114 - Interstellar 114 - Jiro - Pull Up (Original Mix) [Distortion Records]
115 - Jiro - Pull Up (Original Mix) [Distortion Records] 115 - The Beat Is Over
116 - The Beat Is Over 116 - Brothers Of Dub Same Frequency (Future Funk Squad's 'Sonic-Correction' Remix)
117 - Brothers Of Dub Same Frequency (Future Funk Squad's 'Sonic-Correction' Remix) 117 - MÜME - Finger Lickin (original mix) #breakbeat
118 - MÜME - Finger Lickin (original mix) #breakbeat 118 - Old School Flavour
119 - Old School Flavour 119 - I.C.O.N. - Voco Me (Original)
120 - I.C.O.N. - Voco Me (Original) 120 - DJ Icey Low Down Good Girl
121 - DJ Icey Low Down Good Girl 121 - Freestylers Feat. Million Dan - Boom Blast (Deekline & Wizard Feat. Yoland Remix)
122 - Freestylers Feat. Million Dan - Boom Blast (Deekline & Wizard Feat. Yoland Remix) 122 - Phreak
123 - Phreak 123 - Floorfilla - Mr Q Screams Out (Kultür Remix)
124 - Floorfilla - Mr Q Screams Out (Kultür Remix) 124 - Deekline & Wizard - Woah
125 - Deekline & Wizard - Woah 125 - Deekline & Wizard Feat Spoonface - Blo Dem Away
126 - Deekline & Wizard Feat Spoonface - Blo Dem Away 126 - Breakfastaz x Ivory - Girls, Money, Drinks and Drugs
127 - Breakfastaz x Ivory - Girls, Money, Drinks and Drugs 127 - Game Control (Original Mix)
128 - Game Control (Original Mix) 128 - Hell Yeah! (Original Mix)
129 - Hell Yeah! (Original Mix) 129 - X- Rated (Original Mix)
130 - X- Rated (Original Mix) 130 - Omni Trio - Renegade Snares (Aquasky vs Masterblaster Remix)
131 - Omni Trio - Renegade Snares (Aquasky vs Masterblaster Remix) 131 - Quench Dreams (Franxis`90 & Sunrise remix)
132 - Quench Dreams (Franxis`90 & Sunrise remix) 132 - Shadow Breaks (Keep on Movin' Mix - Mixed)
133 - Shadow Breaks (Keep on Movin' Mix - Mixed) 133 - Hold You (Original Mix)
134 - Hold You (Original Mix) 134 - Africa (Sun God Mix)
135 - Africa (Sun God Mix) 135 - War
136 - War 136 - The Rage
137 - The Rage 137 - Afterparty
138 - Afterparty 138 - Wizard & Ivory - Jack In A Box (Aquasky Remix)
139 - Wizard & Ivory - Jack In A Box (Aquasky Remix) 139 - Whats Down Low (Aquasky vs. Masterblaster Breaks Mix)
140 - Whats Down Low (Aquasky vs. Masterblaster Breaks Mix) 140 - Annihilation
141 - Annihilation 141 - Mr. Fli Serious Sound
142 - Mr. Fli Serious Sound 142 - FM-3 & Bowser - Backstage
143 - FM-3 & Bowser - Backstage 143 - Aquasky vs Master Blaster - Thru The Fire (Backdraft Rmx)
144 - Aquasky vs Master Blaster - Thru The Fire (Backdraft Rmx) 144 - DJ Baby Anne 'Mixtress'
145 - DJ Baby Anne 'Mixtress' 145 - PHUTURE ASSASSINS - Ganja Madness (Backdraft Remix) - Warehouse Wax 008
146 - PHUTURE ASSASSINS - Ganja Madness (Backdraft Remix) - Warehouse Wax 008 146 - 2000 & More
147 - 2000 & More 147 - R U Ready, Pt. 2
148 - R U Ready, Pt. 2 148 - Labrat (Backdraft's VIP Mix)
149 - Labrat (Backdraft's VIP Mix) 149 - the autobots vs screwface - Apocalypse.
150 - the autobots vs screwface - Apocalypse. 150 - Baymont bross - Mutanbreakz - Drop the bass .
151 - Baymont bross - Mutanbreakz - Drop the bass . 151 - dr fish - influenza - Sasser Remix.
152 - dr fish - influenza - Sasser Remix. 152 - conectivers and bikto -The quarantine .
153 - conectivers and bikto -The quarantine . 153 - Backdraft - Nicotine
154 - Backdraft - Nicotine 154 - Concentrate
155 - Concentrate 155 - Doc Zee & Greenflamez - Set Me Free
156 - Doc Zee & Greenflamez - Set Me Free 156 - Big Eyes
157 - Big Eyes 157 - Anonymous (D-Fast Beats Remix)
158 - Anonymous (D-Fast Beats Remix) 158 - Nation of Love (GreenFlamez & Dr Black Sheep Remix)
159 - Nation of Love (GreenFlamez & Dr Black Sheep Remix) 159 - DJ QUEST & DJ ODISSI - Break Me (Original Pyramid Remix) @breakbeatologia
160 - DJ QUEST & DJ ODISSI - Break Me (Original Pyramid Remix) @breakbeatologia 160 - No Heaven
161 - No Heaven 161 - Amnexiac - Surrender (original mix)
162 - Amnexiac - Surrender (original mix) 162 - Westbam - Beatbox Rocker
163 - Westbam - Beatbox Rocker 163 - *1995 * Rennie Pilgrem - A Place Called Acid [ TEMAZO RETRO BREAKBEAT ]
164 - *1995 * Rennie Pilgrem - A Place Called Acid [ TEMAZO RETRO BREAKBEAT ] 164 - *2002* Aka - Bubblegum 2 [ Temazo Retro Breakbeat ]
165 - *2002* Aka - Bubblegum 2 [ Temazo Retro Breakbeat ] 165 - *2004* Distortionz - Can of Worms [ Temazo Retro Breakbeat ]
166 - *2004* Distortionz - Can of Worms [ Temazo Retro Breakbeat ] 166 - CTRL Z Vs The Autobots Vs Screwface - Karma
167 - CTRL Z Vs The Autobots Vs Screwface - Karma 167 - Pink Elephant vs Backdraft - Better L8 Than Never
168 - The Breakfastaz - Spit It Out 168 - Back Again
169 - Pink Elephant vs Backdraft - Better L8 Than Never 169 - Will Azada - Mysterious White Powder (Original Mix) [Hypercolour]
170 - Back Again 170 - Energy Mash (Aquasky vs. Masterblaster)
171 - Will Azada - Mysterious White Powder (Original Mix) [Hypercolour] 171 - Megatron (Aquasky vs. Masterblaster)
172 - Energy Mash (Aquasky vs. Masterblaster) 172 - Krafty Kuts & Skool Of Thought - Devastate
173 - Megatron (Aquasky vs. Masterblaster) 173 - Old Groove
174 - Krafty Kuts & Skool Of Thought - Devastate 174 - Ctrl Z, Screwface and Stereotype - Dusk Til Dawn (demeNtial BPM Mix)
175 - Old Groove 175 - Dylan Rhymes & Pablo Decoder - I am Sweet (Ctrl Z RemiX)
176 - Ctrl Z, Screwface and Stereotype - Dusk Til Dawn (demeNtial BPM Mix) 176 - The Autobots vs Screwface - Flesh Eater
177 - Dylan Rhymes & Pablo Decoder - I am Sweet (Ctrl Z RemiX) 177 - Koma & Bones - Get Down (The Breakfastaz remix)
178 - The Autobots vs Screwface - Flesh Eater 178 - D-Ranged - Killer Spiderz
179 - Koma & Bones - Get Down (The Breakfastaz remix) 179 - Wayward Soul Wild Child
180 - D-Ranged - Killer Spiderz 180 - Rave In The Moon
181 - Wayward Soul Wild Child 181 - Revolution
182 - Rave In The Moon 182 - Blood For Everyone
183 - Revolution 183 - Plump DJs feat Gary Numan - Pray For You (Lee Coombs Remix)
184 - Blood For Everyone 184 - J.D.S. Daylight
185 - Plump DJs feat Gary Numan - Pray For You (Lee Coombs Remix) 185 - Avion
186 - J.D.S. Daylight 186 - Vortex (Original Mix)
187 - Avion 187 - Libre (Bad Legs Remix)
188 - Vortex (Original Mix) 188 - Angel Dust Remix (FFS Remix)
189 - Libre (Bad Legs Remix) 189 - Autobots_-_Blogger
190 - Angel Dust Remix (FFS Remix) 190 - Time Out
191 - Autobots_-_Blogger 191 - Breakbeat nation vol.1. Dziblio--After Hours
192 - Time Out 192 - I Need A Breakbeat
193 - Breakbeat nation vol.1. Dziblio--After Hours 193 - Elektronauts - Bumper (Plump DJs Vocal Mix)
194 - I Need A Breakbeat 194 - Player One Into The Darkness (Original Mix)
195 - Elektronauts - Bumper (Plump DJs Vocal Mix) 195 - Bill Vega & New Decade - Mind Beats
196 - Player One Into The Darkness (Original Mix) 196 - Stepsine - Gen Sec of Breaks
197 - Bill Vega & New Decade - Mind Beats 197 - Freeflow 45 - Peaktime
198 - Stepsine - Gen Sec of Breaks 198 - Take Me Away (XTC Come Hard Mix)
199 - Freeflow 45 - Peaktime 199 - Kay Cee - Unsolved Mysteries (Elektrochemie LK Remix)
200 - Take Me Away (XTC Come Hard Mix) 200 - M.A.N.I.C. - I'm Coming Hardcore '96 (Original Mix)
201 - Kay Cee - Unsolved Mysteries (Elektrochemie LK Remix) 201 - Excuses For Skipping - Tonic For Hysteria (Simon Apex & Smart Bomb Remix)
202 - M.A.N.I.C. - I'm Coming Hardcore '96 (Original Mix) 202 - Esion - Buzzin
203 - Excuses For Skipping - Tonic For Hysteria (Simon Apex & Smart Bomb Remix) 203 - Amunition (Original Mix)
204 - Esion - Buzzin 204 - The Wiggle
205 - Amunition (Original Mix) 205 - Private video
206 - The Wiggle 206 - Menorca
207 - Awesome 3 - Don't Go (KLAM Mix) 207 - Case 82 & Dazzler - Deep Inside (Original Mix)
208 - Menorca 208 - Dogzilla (Chris Carter & JHZ Feat SKB) - Big Chat
209 - Case 82 & Dazzler - Deep Inside (Original Mix) 209 - Wu Tang
210 - Dogzilla (Chris Carter & JHZ Feat SKB) - Big Chat 210 - Hardcore Man
211 - Wu Tang 211 - The Monster
212 - Hardcore Man 212 - Abyss
213 - The Monster 213 - Skinwalkers
214 - Abyss 214 - Dj Kultur Everybody Get Up
215 - Skinwalkers 215 - Kultür - Evassion4Ever (Take 1)
216 - Dj Kultur Everybody Get Up 216 - Quadrophonia  Quadrophonia (Nu Skool Breaks Remix) @DjMarcioDanceSjp
217 - Kultür - Evassion4Ever (Take 1) 217 - Spit It Out - The Breakfastaz
218 - Quadrophonia  Quadrophonia (Nu Skool Breaks Remix) @DjMarcioDanceSjp 218 - Infiniti - Running Away
219 - Aquasky - Structure
220 - "Make Me Feel Good" - Dj Icey
221 - Rasco & Peaky Beats - Cats In Seville
222 - Flaunting
223 - Say my name
224 - Dreamers
225 - Enigma
226 - It Takes Me Up
227 - Karuma On Y Va (Kultür Remix)
228 - Dj RiCeY - Castles in the Sky (Break Beat)
229 - The Breakfastaz - Kick It
230 - DJ Mike B Into The Groove
231 - Freq Nasty - Brooklyn to Brixton (Freestylers Raw as fuck remix).wmv
232 - Mark Ruff Ryder - We Do It Ruff (Vs Joy Mega Mix)
233 - Sly Fidelity - Skin & Bone (Rennie Pilgrem & Blim Mix)
234 - Lee Coombs - Future Sound Of Retro
235 - Splitloop - Panic Mechanic (Original Mix)
236 - Nectarios - Pheonix (Vigi And Nectarios Mix)
237 - Stereo 8 - Stamina Feat Jakes
238 - Dee Pattern Vs J.D.S. Who's The Bad Man (Untitled Mix 1)
239 - CHRIS CARTER: ESP (2022 Remaster)
240 - Masthaz of Phunk - Masthaz of Phunk (Phat Mixz)
241 - Dee Pattern Vs J.D.S. Who's The Bad Man (Untitled Mix 2)
242 - Vlad & Ardisson - Metrognome (Smithmonger remix)
243 - Drumattic Twins - Thinkin' About You Baby
244 - Bass City Rollaz - Everybody Get Funky
245 - Plump DJs - Big Groovy Fucker
246 - Arthur Baker vs Rennie Pilgrem - Like no other (Rennie Pilgrem Mix)
247 - Hoffman - Everybody
248 - Bad Habits 2008 Remix - Portal - 2FX / 2 Fresh - Hardcore Breaks / HCB / Oldskool / Rave / Piano
249 - Semi Detached - Funky Plucker!
250 - Dave London - Breathe Deep (Infiniti Remix)
251 - Bass City Rollaz - Bad One
252 - Qb Project - in Time (Pete Voyagers Mix)
253 - Cut & Run Loneliness
254 - Peacemaker - Last Train (Original Mix)
255 - Black Mushroom - Don't Clap Anybody (Ecstatica Mix)
256 - Cobra (Chris Carter Remix) (Aquasky Vs. Masterblaster)
257 - Cut & Paste - Forget It (Original Krinkle Kut)
258 - Royksopp - What Else Is There (Trentemoller Breaks Mix)
259 - Swordpen (Original Mix)
260 - Cut & Run - Palinka / Beatman and Ludmilla - Inka (Backdraft remix)
261 - Aquasky - Sucker Punch
262 - Alieneye - Found A Cafe (Mix 2)
263 - Anuschka - Feel The Generation
264 - DJ 43 Pepper Spray (I Wouldn't Want That Sprayed In My Face Remix)
265 - Orbital - Kein Trink Wasser
266 - Ctrl Z vs Screwface [Stereo Typical]
267 - Balls To The Wall (Stereo:Typical Pt. 2) (Original Mix)
268 - Turn up the Music (Dr Black Sheep Remix)
269 - The Silence (Matt Darey Tekara Mix)
270 - dj Isy - Adrenaline
271 - Transformer Man - Hell Hound (Kem Remix)
272 - Brainkiller - Destroy The World
273 - Influenza - Let Me Fall ( KmFx rmx )

View File

@@ -10,32 +10,28 @@ import re
from googleapiclient.discovery import build from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow from google_auth_oauthlib.flow import InstalledAppFlow
import googleapiclient.errors
scopes = ["https://www.googleapis.com/auth/youtube.force-ssl"] scopes = ["https://www.googleapis.com/auth/youtube.force-ssl"]
channels = { channels = {
"breakbeat_sesiones":"PLZFfy80_qguYVqbpQlX-aHdiYHTwc6-wW", "breakbeat_sesiones": "PLZFfy80_qguYVqbpQlX-aHdiYHTwc6-wW",
"breakbeat_temas":"PLZFfy80_qguZnpBYfSFlkMdjGIfVcz7e7", "breakbeat_temas": "PLZFfy80_qguZnpBYfSFlkMdjGIfVcz7e7",
"wods": "PLZFfy80_qguYCbTDQD0GSK4zUzEjbQMQT", "wods": "PLZFfy80_qguYCbTDQD0GSK4zUzEjbQMQT",
"rap_español": "PLZFfy80_qgub44wWWDcAykdQCJNCXo4jp", "rap_español": "PLZFfy80_qgub44wWWDcAykdQCJNCXo4jp",
} }
def get_playlist_length(youtube, playlist_id): def get_playlist_length(youtube, playlist_id):
items = youtube.playlists().list( items = youtube.playlists().list(part="snippet,contentDetails", id=playlist_id)
part="snippet,contentDetails",
id=playlist_id
)
playlist_info = items.execute() playlist_info = items.execute()
return playlist_info['items'][0]['contentDetails']['itemCount'] return playlist_info["items"][0]["contentDetails"]["itemCount"]
def list_songs(youtube, channel_id, stdout=False): def list_songs(youtube, channel_id, stdout=False):
max_results = 50 max_results = 50
request = youtube.playlistItems().list( request = youtube.playlistItems().list(
part="snippet,contentDetails", part="snippet,contentDetails", maxResults=max_results, playlistId=channel_id
maxResults=max_results,
playlistId=channel_id
) )
response = request.execute() response = request.execute()
print() print()
@@ -43,9 +39,9 @@ def list_songs(youtube, channel_id, stdout=False):
# Process the first page of results # Process the first page of results
deleted = 0 deleted = 0
songs_list = [] songs_list = []
for idx, item in enumerate(response['items'], start=1): for idx, item in enumerate(response["items"], start=1):
title = item['snippet']['title'] title = item["snippet"]["title"]
if title == "Deleted video": if title == "Deleted video":
deleted += 1 deleted += 1
continue continue
@@ -53,36 +49,43 @@ def list_songs(youtube, channel_id, stdout=False):
# Continue making requests for additional pages using pageToken # Continue making requests for additional pages using pageToken
new_starting = 51 new_starting = 51
while 'nextPageToken' in response: while "nextPageToken" in response:
request = youtube.playlistItems().list( request = youtube.playlistItems().list(
part='snippet', part="snippet",
playlistId=channel_id, playlistId=channel_id,
maxResults=max_results, maxResults=max_results,
pageToken=response['nextPageToken'] pageToken=response["nextPageToken"],
) )
response = request.execute() response = request.execute()
# Process the results for the additional pages # Process the results for the additional pages
for idx, item in enumerate(response['items'], start=new_starting): for idx, item in enumerate(response["items"], start=new_starting):
title = item['snippet']['title'] title = item["snippet"]["title"]
if title == "Deleted video": if title == "Deleted video":
deleted += 1 deleted += 1
continue continue
songs_list.append(f"{idx-deleted:02d} - {title}") songs_list.append(f"{idx-deleted:02d} - {title}")
new_starting += 50 new_starting += 50
if stdout: if stdout:
# Print to standard output # Print to standard output
print("\n".join(songs_list)) print("\n".join(songs_list))
get_key_by_value = lambda dict, val: next((k for k, v in dict.items() if v == val), None) # get_key_by_value = lambda dict, val: next(
# (k for k, v in dict.items() if v == val), None
channel_name = get_key_by_value(channels, channel_id) # )
def _get_key_by_value(dict, val):
return next((k for k, v in dict.items() if v == val), None)
channel_name = _get_key_by_value(channels, channel_id)
# Save to file if output_file is provided # Save to file if output_file is provided
with open(f"{channel_name} songs", 'w', encoding='utf-8') as file: with open(f"{channel_name} songs", "w", encoding="utf-8") as file:
file.write("\n".join(songs_list)) file.write("\n".join(songs_list))
print("\nList created successfully!")
def add_song(youtube, channel_id, song): def add_song(youtube, channel_id, song):
pos = get_playlist_length(youtube, channel_id) pos = get_playlist_length(youtube, channel_id)
@@ -92,25 +95,27 @@ def add_song(youtube, channel_id, song):
"snippet": { "snippet": {
"playlistId": channel_id, "playlistId": channel_id,
"position": pos, "position": pos,
"resourceId": { "resourceId": {"kind": "youtube#video", "videoId": song},
"kind": "youtube#video",
"videoId": song
}
} }
} },
) )
response = request.execute() # response = request.execute()
request.execute()
print("\nSong added successfully!") print("\nSong added successfully!")
def main(): def main():
parser = argparse.ArgumentParser(description="Manage YouTube playlist songs.") parser = argparse.ArgumentParser(description="Manage YouTube playlist songs.")
parser.add_argument("-l", "--list", action="store_true", help="List songs in the playlist") parser.add_argument(
parser.add_argument("-a", "--add", metavar="song", help="Add a song to the playlist") "-l", "--list", metavar="channel_name", help="List songs in the playlist"
parser.add_argument("channel_name", help="Name of the playlist") )
parser.add_argument(
"-a", "--add", metavar="channel_name", help="Name of the playlist"
)
parser.add_argument("song", nargs="?", help="Name of the song")
args = parser.parse_args() args = parser.parse_args()
channel_name = args.channel_name channel_name = args.add or args.list
channel_id = channels.get(channel_name) channel_id = channels.get(channel_name)
if not args.list and not args.add: if not args.list and not args.add:
@@ -124,27 +129,27 @@ def main():
# *DO NOT* leave this option enabled in production. # *DO NOT* leave this option enabled in production.
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1" os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
api_service_name = "youtube" # scopes is a global variable
api_version = "v3"
client_secret = "./client_secrets.json" client_secret = "./client_secrets.json"
flow = InstalledAppFlow.from_client_secrets_file(client_secret, scopes)
flow = InstalledAppFlow.from_client_secrets_file(
client_secret, scopes)
credentials = flow.run_local_server(port=0) credentials = flow.run_local_server(port=0)
youtube = build( api_service_name = "youtube"
api_service_name, api_version, api_version = "v3"
credentials=credentials) youtube = build(api_service_name, api_version, credentials=credentials)
if args.list: if args.list:
list_songs(youtube, channel_id, stdout=False) list_songs(youtube, channel_id, stdout=False)
elif args.add: elif args.add:
song = args.add if not args.song:
# # this assumes a song is passed as in either of the following ways parser.error("Please provide the name of the song with -a.")
# # https://youtu.be/eEnyi9L6KP4 --> split by "/" song = args.song
# # https://youtube.com/watch?v=Ez-gizOF0Wo --> split by "=" # this assumes a song is passed as in either of the following ways
# https://youtu.be/eEnyi9L6KP4 --> split by "/"
# https://youtube.com/watch?v=Ez-gizOF0Wo --> split by "="
song = re.split(r"/|=", song)[-1] song = re.split(r"/|=", song)[-1]
add_song(youtube, channel_id, song) add_song(youtube, channel_id, song)
if __name__ == "__main__": if __name__ == "__main__":
main() main()