-
Notifications
You must be signed in to change notification settings - Fork 0
/
ytmusicPlaylistDoubleYouMixAreShe.py
59 lines (52 loc) · 1.77 KB
/
ytmusicPlaylistDoubleYouMixAreShe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import random
from ytmusicapi import YTMusic
from ytmusicFunctions import AddToPlaylist, ClearPlaylist
from ytmusicFunctions import GetPlaylistTrackCount
def MixChicagoRadioStations(ytmusic:YTMusic) -> bool:
shePlaylistId = "PLJpUfuX6t6dTyEfFJmvVlIGzcXR1dKFt5"
xrtPlaylistId = "PLJpUfuX6t6dSaHuu1oeQHWhmMTM6G_hKw"
mixPlaylistId = "PLJpUfuX6t6dS__5F2qgcopS26s5MbO8Yd"
wmrsPlaylistId = "PLJpUfuX6t6dSQDudst4PXxL_vo3T1uOd4"
playlistTrackCount = {
xrtPlaylistId: 64,
shePlaylistId: 48,
mixPlaylistId: 16,
}
collectedVideoIds = []
for playlistId, count in playlistTrackCount.items():
playlistData = ytmusic.get_playlist(
playlistId=playlistId,
limit=GetPlaylistTrackCount(
ytmusic=ytmusic,
playlistId=playlistId
)
)
songIds = [
track['videoId'] for track in playlistData['tracks']
]
random.shuffle(songIds)
addCount = 0
for songId in songIds:
if addCount >= count:
break
if songId in collectedVideoIds:
continue
collectedVideoIds.append(songId)
addCount += 1
ClearPlaylist(ytmusic=ytmusic, playlistId=wmrsPlaylistId)
random.shuffle(collectedVideoIds)
results = [
AddToPlaylist(
ytmusic=ytmusic,
playlistId=wmrsPlaylistId,
videoId=videoId
) for videoId in collectedVideoIds
]
return sum(results) > 0
if __name__ == "__main__":
ytmusic = YTMusic("oauth.json")
print("Updating Double You Mix Are She playlist")
if MixChicagoRadioStations(ytmusic=ytmusic):
print("Playlist update successful")
else:
print("Error updating playlist")