did the needful
This commit is contained in:
parent
785d187c2f
commit
e93914745e
20
Pipfile
Normal file
20
Pipfile
Normal file
@ -0,0 +1,20 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
requests = "*"
|
||||
ytmusicapi = "*"
|
||||
uuid = "*"
|
||||
dpath = "*"
|
||||
pathlib = "*"
|
||||
numpy = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.6"
|
||||
|
||||
[scripts]
|
||||
eggsecute = "python shuffler.py"
|
130
Pipfile.lock
generated
Normal file
130
Pipfile.lock
generated
Normal file
@ -0,0 +1,130 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "a8f2591870202c097da45f89a2c17ff6dba87785879d9f36d37c73d9dc87402d"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.6"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"certifi": {
|
||||
"hashes": [
|
||||
"sha256:9c5705e395cd70084351dd8ad5c41e65655e08ce46f2ec9cf6c2c08390f71eb7",
|
||||
"sha256:f1d53542ee8cbedbe2118b5686372fb33c297fcd6379b050cca0ef13a597382a"
|
||||
],
|
||||
"version": "==2022.5.18.1"
|
||||
},
|
||||
"charset-normalizer": {
|
||||
"hashes": [
|
||||
"sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597",
|
||||
"sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"
|
||||
],
|
||||
"markers": "python_version >= '3'",
|
||||
"version": "==2.0.12"
|
||||
},
|
||||
"dpath": {
|
||||
"hashes": [
|
||||
"sha256:5a1ddae52233fbc8ef81b15fb85073a81126bb43698d3f3a1b6aaf561a46cdc0",
|
||||
"sha256:8c439bb1c3b3222427e9b8812701cd99a0ef3415ddbb7c03a2379f6989a03965"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.0.6"
|
||||
},
|
||||
"idna": {
|
||||
"hashes": [
|
||||
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
|
||||
"sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
|
||||
],
|
||||
"markers": "python_version >= '3'",
|
||||
"version": "==3.3"
|
||||
},
|
||||
"numpy": {
|
||||
"hashes": [
|
||||
"sha256:012426a41bc9ab63bb158635aecccc7610e3eff5d31d1eb43bc099debc979d94",
|
||||
"sha256:06fab248a088e439402141ea04f0fffb203723148f6ee791e9c75b3e9e82f080",
|
||||
"sha256:0eef32ca3132a48e43f6a0f5a82cb508f22ce5a3d6f67a8329c81c8e226d3f6e",
|
||||
"sha256:1ded4fce9cfaaf24e7a0ab51b7a87be9038ea1ace7f34b841fe3b6894c721d1c",
|
||||
"sha256:2e55195bc1c6b705bfd8ad6f288b38b11b1af32f3c8289d6c50d47f950c12e76",
|
||||
"sha256:2ea52bd92ab9f768cc64a4c3ef8f4b2580a17af0a5436f6126b08efbd1838371",
|
||||
"sha256:36674959eed6957e61f11c912f71e78857a8d0604171dfd9ce9ad5cbf41c511c",
|
||||
"sha256:384ec0463d1c2671170901994aeb6dce126de0a95ccc3976c43b0038a37329c2",
|
||||
"sha256:39b70c19ec771805081578cc936bbe95336798b7edf4732ed102e7a43ec5c07a",
|
||||
"sha256:400580cbd3cff6ffa6293df2278c75aef2d58d8d93d3c5614cd67981dae68ceb",
|
||||
"sha256:43d4c81d5ffdff6bae58d66a3cd7f54a7acd9a0e7b18d97abb255defc09e3140",
|
||||
"sha256:50a4a0ad0111cc1b71fa32dedd05fa239f7fb5a43a40663269bb5dc7877cfd28",
|
||||
"sha256:603aa0706be710eea8884af807b1b3bc9fb2e49b9f4da439e76000f3b3c6ff0f",
|
||||
"sha256:6149a185cece5ee78d1d196938b2a8f9d09f5a5ebfbba66969302a778d5ddd1d",
|
||||
"sha256:759e4095edc3c1b3ac031f34d9459fa781777a93ccc633a472a5468587a190ff",
|
||||
"sha256:7fb43004bce0ca31d8f13a6eb5e943fa73371381e53f7074ed21a4cb786c32f8",
|
||||
"sha256:811daee36a58dc79cf3d8bdd4a490e4277d0e4b7d103a001a4e73ddb48e7e6aa",
|
||||
"sha256:8b5e972b43c8fc27d56550b4120fe6257fdc15f9301914380b27f74856299fea",
|
||||
"sha256:99abf4f353c3d1a0c7a5f27699482c987cf663b1eac20db59b8c7b061eabd7fc",
|
||||
"sha256:a0d53e51a6cb6f0d9082decb7a4cb6dfb33055308c4c44f53103c073f649af73",
|
||||
"sha256:a12ff4c8ddfee61f90a1633a4c4afd3f7bcb32b11c52026c92a12e1325922d0d",
|
||||
"sha256:a4646724fba402aa7504cd48b4b50e783296b5e10a524c7a6da62e4a8ac9698d",
|
||||
"sha256:a76f502430dd98d7546e1ea2250a7360c065a5fdea52b2dffe8ae7180909b6f4",
|
||||
"sha256:a9d17f2be3b427fbb2bce61e596cf555d6f8a56c222bd2ca148baeeb5e5c783c",
|
||||
"sha256:ab83f24d5c52d60dbc8cd0528759532736b56db58adaa7b5f1f76ad551416a1e",
|
||||
"sha256:aeb9ed923be74e659984e321f609b9ba54a48354bfd168d21a2b072ed1e833ea",
|
||||
"sha256:c843b3f50d1ab7361ca4f0b3639bf691569493a56808a0b0c54a051d260b7dbd",
|
||||
"sha256:cae865b1cae1ec2663d8ea56ef6ff185bad091a5e33ebbadd98de2cfa3fa668f",
|
||||
"sha256:cc6bd4fd593cb261332568485e20a0712883cf631f6f5e8e86a52caa8b2b50ff",
|
||||
"sha256:cf2402002d3d9f91c8b01e66fbb436a4ed01c6498fffed0e4c7566da1d40ee1e",
|
||||
"sha256:d051ec1c64b85ecc69531e1137bb9751c6830772ee5c1c426dbcfe98ef5788d7",
|
||||
"sha256:d6631f2e867676b13026e2846180e2c13c1e11289d67da08d71cacb2cd93d4aa",
|
||||
"sha256:dbd18bcf4889b720ba13a27ec2f2aac1981bd41203b3a3b27ba7a33f88ae4827",
|
||||
"sha256:df609c82f18c5b9f6cb97271f03315ff0dbe481a2a02e56aeb1b1a985ce38e60"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.19.5"
|
||||
},
|
||||
"pathlib": {
|
||||
"hashes": [
|
||||
"sha256:6940718dfc3eff4258203ad5021090933e5c04707d5ca8cc9e73c94a7894ea9f",
|
||||
"sha256:f35f95ab8b0f59e6d354090350b44a80a80635d22efdedfa84c7ad1cf0a74147"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.0.1"
|
||||
},
|
||||
"requests": {
|
||||
"hashes": [
|
||||
"sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61",
|
||||
"sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.27.1"
|
||||
},
|
||||
"urllib3": {
|
||||
"hashes": [
|
||||
"sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14",
|
||||
"sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e"
|
||||
],
|
||||
"version": "==1.26.9"
|
||||
},
|
||||
"uuid": {
|
||||
"hashes": [
|
||||
"sha256:1f87cc004ac5120466f36c5beae48b4c48cc411968eed0eaecd3da82aa96193f"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.30"
|
||||
},
|
||||
"ytmusicapi": {
|
||||
"hashes": [
|
||||
"sha256:099e2ea16e141e7e42f8c724417cac4ddc9d680a67f7d6f45029c5e513dbec32",
|
||||
"sha256:d042520f3f76eac2c1498130dbc4e8a4af21ca73496590a5ff054fc4da0af1d8"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.22.0"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
52
shuffler.py
Normal file
52
shuffler.py
Normal file
@ -0,0 +1,52 @@
|
||||
import json
|
||||
import datetime as dt
|
||||
import os
|
||||
from dpath import util
|
||||
import numpy as np
|
||||
from ytmusicapi import YTMusic
|
||||
ytmusic = YTMusic("config.json")
|
||||
# created a config file following the docs here: https://ytmusicapi.readthedocs.io/en/latest/setup.html
|
||||
# I tried the "interactive" authentication but wasn't having luck with it
|
||||
|
||||
|
||||
# Add the name of the playlist you want to shuffle here
|
||||
to_shuffle = 'Sleep'
|
||||
|
||||
|
||||
def get_playlistID(name):
|
||||
playlistID = ytmusic.get_library_playlists(limit=100)
|
||||
for i in playlistID:
|
||||
if i['title'] == name:
|
||||
return i['playlistId']
|
||||
|
||||
# back up the playlist, just in case.
|
||||
bkup_title = to_shuffle + ' autobackup'
|
||||
if get_playlistID(bkup_title):
|
||||
ytmusic.delete_playlist(get_playlistID(bkup_title))
|
||||
backup = {}
|
||||
backup['source_playlist'] = get_playlistID(to_shuffle)
|
||||
backup['title'] = bkup_title
|
||||
now = dt.datetime.now()
|
||||
now = now.strftime("%Y-%m-%d %H:%M")
|
||||
backup['description'] = 'Created ' + now
|
||||
ytmusic.create_playlist(**backup)
|
||||
|
||||
playlist = ytmusic.get_playlist(get_playlistID(to_shuffle), limit=1000) #get the songs in the playlist
|
||||
track_ids = []
|
||||
for i in playlist['tracks']:
|
||||
track_ids.append(i['videoId'])
|
||||
np.random.shuffle(track_ids)
|
||||
privacy = playlist['privacy']
|
||||
|
||||
ytmusic.delete_playlist(get_playlistID(to_shuffle))
|
||||
|
||||
shuffled = {}
|
||||
shuffled['title'] = to_shuffle
|
||||
now = dt.datetime.now()
|
||||
now = now.strftime("%Y-%m-%d %H:%M")
|
||||
shuffled['description'] = 'Shuffled ' + now
|
||||
shuffled['video_ids'] = track_ids
|
||||
shuffled['privacy_status'] = privacy
|
||||
ytmusic.create_playlist(**shuffled)
|
||||
print(f'The playlist called \"{to_shuffle}\" has been shuffled!')
|
||||
#TODO and UI: auth and playlist name
|
Loading…
Reference in New Issue
Block a user