started link getter
This commit is contained in:
parent
630fefc877
commit
95effbc878
BIN
src/__pycache__/download_links.cpython-310.pyc
Normal file
BIN
src/__pycache__/download_links.cpython-310.pyc
Normal file
Binary file not shown.
42
src/download_links.py
Normal file
42
src/download_links.py
Normal file
@ -0,0 +1,42 @@
|
||||
from turtle import down
|
||||
import pandas as pd
|
||||
import requests
|
||||
|
||||
# https://musify.club/search/suggestions?term=happy days
|
||||
|
||||
class Download:
|
||||
def __init__(self, metadata_csv: str = ".cache.csv", session: requests.Session = requests.Session()) -> None:
|
||||
self.session = session
|
||||
self.session.headers = {
|
||||
"Connection": "keep-alive",
|
||||
"Referer": "https://musify.club/"
|
||||
}
|
||||
|
||||
self.metadata = pd.read_csv(metadata_csv, index_col=0)
|
||||
print(self.metadata)
|
||||
|
||||
self.check_musify()
|
||||
|
||||
def check_musify_track(self, row):
|
||||
artist = row['artist']
|
||||
track = row['title']
|
||||
|
||||
url = f"https://musify.club/search/suggestions?term={track}"
|
||||
|
||||
r = self.session.get(url=url)
|
||||
if r.status_code == 200:
|
||||
autocomplete = r.json()
|
||||
for row in autocomplete:
|
||||
print(artist, row['label'], artist in row['label'])
|
||||
if artist in row['label']:
|
||||
print(row)
|
||||
break
|
||||
|
||||
def check_musify(self):
|
||||
for idx, row in self.metadata.iterrows():
|
||||
url = self.check_musify_track(row)
|
||||
break
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
download = Download()
|
@ -1,4 +1,5 @@
|
||||
import metadata
|
||||
import download_links
|
||||
|
||||
|
||||
def search_for_metadata(query: str):
|
||||
@ -27,6 +28,8 @@ def cli():
|
||||
search = search_for_metadata(query=input("initial query: "))
|
||||
search.download()
|
||||
|
||||
download = download_links.Download()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
Loading…
Reference in New Issue
Block a user