mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Even more logging in spotify download
Fix #1 Test fix 2 Fixing part 2 Fixing ctnd Final fix Fixing spotipy get bug Same plusy kurwa Fixing fucking spotipy test More logging
This commit is contained in:
@@ -1064,11 +1064,15 @@ async def get_file(ctx, source, link):
|
|||||||
if source == "Spotify":
|
if source == "Spotify":
|
||||||
dir_path = None
|
dir_path = None
|
||||||
item_type, item_id = spotify.parse_spotify_url(link)
|
item_type, item_id = spotify.parse_spotify_url(link)
|
||||||
if item_id:
|
if item_type in ["album", "track", "playlist"] and item_id:
|
||||||
coro = asyncio.to_thread(spotify.fetch_tracks, spotify_ctrl, item_type, link)
|
logger.info(item_type)
|
||||||
file_list = await coro
|
logger.info(item_id)
|
||||||
coro = asyncio.to_thread(spotify.get_item_name, spotify_ctrl, item_type, item_id)
|
logger.info("Spotify link provided")
|
||||||
directory_name = await coro
|
file_list = await asyncio.to_thread(spotify.fetch_tracks, spotify_ctrl, item_type, link)
|
||||||
|
logger.info(file_list)
|
||||||
|
directory_name = await asyncio.to_thread(spotify.get_item_name, spotify_ctrl, item_type, item_id)
|
||||||
|
logger.info(directory_name)
|
||||||
|
logger.info("Spotify scrape done")
|
||||||
url_data = {"urls": []}
|
url_data = {"urls": []}
|
||||||
url_dict = {}
|
url_dict = {}
|
||||||
url_dict["save_path"] = Path(
|
url_dict["save_path"] = Path(
|
||||||
@@ -1078,6 +1082,7 @@ async def get_file(ctx, source, link):
|
|||||||
url_dict["songs"] = file_list
|
url_dict["songs"] = file_list
|
||||||
url_data["urls"].append(url_dict.copy())
|
url_data["urls"].append(url_dict.copy())
|
||||||
file_name_f = youtube_download.default_filename
|
file_name_f = youtube_download.default_filename
|
||||||
|
logger.info("YT-DL")
|
||||||
coro = asyncio.to_thread(
|
coro = asyncio.to_thread(
|
||||||
youtube_download.download_songs,
|
youtube_download.download_songs,
|
||||||
songs=url_data,
|
songs=url_data,
|
||||||
@@ -1093,6 +1098,7 @@ async def get_file(ctx, source, link):
|
|||||||
proxy="",
|
proxy="",
|
||||||
)
|
)
|
||||||
_ = await coro
|
_ = await coro
|
||||||
|
logger.info("YT-DL done")
|
||||||
dir_path = (url_dict["save_path"].resolve()).as_posix()
|
dir_path = (url_dict["save_path"].resolve()).as_posix()
|
||||||
if platform == "win32":
|
if platform == "win32":
|
||||||
dir_path = dir_path.replace("/", "\\")
|
dir_path = dir_path.replace("/", "\\")
|
||||||
@@ -1829,9 +1835,8 @@ async def wyczysc_ulubione(ctx):
|
|||||||
"""
|
"""
|
||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
coroutine = asyncio.to_thread(
|
coroutine = asyncio.to_thread(
|
||||||
requests.post,
|
requests.get,
|
||||||
f"{FILE_SERVICE_ADDRESS}{CLEAR_PRIO}",
|
f"{FILE_SERVICE_ADDRESS}{CLEAR_PRIO}",
|
||||||
json={},
|
|
||||||
timeout=360,
|
timeout=360,
|
||||||
)
|
)
|
||||||
_ = await coroutine
|
_ = await coroutine
|
||||||
|
|||||||
@@ -41,41 +41,6 @@ if platform in ("linux", "linux2"):
|
|||||||
music_file_list = []
|
music_file_list = []
|
||||||
priority_list = []
|
priority_list = []
|
||||||
|
|
||||||
|
|
||||||
def create_playlist():
|
|
||||||
"""
|
|
||||||
Reads a JSON file containing a playlist and writes the playlist items to a text file.
|
|
||||||
|
|
||||||
The JSON file path is '/home/pi/Conjurer/playlist.json',
|
|
||||||
and the text file path is '/home/pi/Conjurer/all_playlist.playlist'.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
JSONDecodeError: If the JSON file cannot be decoded.
|
|
||||||
|
|
||||||
"""
|
|
||||||
with open("/home/pi/Conjurer/playlist.json", "r+", encoding="utf-8") as r_file:
|
|
||||||
with open(
|
|
||||||
"/home/pi/Conjurer/all_playlist.playlist", "w", encoding="utf-8"
|
|
||||||
) as w_file:
|
|
||||||
try:
|
|
||||||
playlist = json.load(r_file)
|
|
||||||
for item in playlist:
|
|
||||||
w_file.write(item)
|
|
||||||
w_file.write("\n")
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
with open("/home/pi/Conjurer/prio_playlist.json", "r+", encoding="utf-8") as r_file:
|
|
||||||
with open("/home/pi/Conjurer/hit.playlist", "w", encoding="utf-8") as w_file:
|
|
||||||
try:
|
|
||||||
playlist = json.load(r_file)
|
|
||||||
for item in playlist:
|
|
||||||
w_file.write(item)
|
|
||||||
w_file.write("\n")
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def rescan():
|
def rescan():
|
||||||
"""
|
"""
|
||||||
The `rescan` function logs a message, scans for mp3 files in a specified folder,
|
The `rescan` function logs a message, scans for mp3 files in a specified folder,
|
||||||
@@ -95,18 +60,22 @@ def rescan():
|
|||||||
temp_music_file = temp_music_file.replace("/", "\\")
|
temp_music_file = temp_music_file.replace("/", "\\")
|
||||||
priority_list.append(temp_music_file)
|
priority_list.append(temp_music_file)
|
||||||
|
|
||||||
with open("/home/pi/Conjurer/playlist.json", "r+", encoding="utf-8") as s_file:
|
with open(
|
||||||
database = music_file_list
|
"/home/pi/Conjurer/all_playlist.playlist", "w", encoding="utf-8"
|
||||||
# self.app.logger.info("DUMPING DATA")
|
) as w_file:
|
||||||
s_file.truncate(0)
|
try:
|
||||||
s_file.seek(0)
|
for item in music_file_list:
|
||||||
json.dump(database, s_file)
|
w_file.write(item)
|
||||||
with open("/home/pi/Conjurer/prio_playlist.json", "r+", encoding="utf-8") as s_file:
|
w_file.write("\n")
|
||||||
# self.app.logger.info("DUMPING DATA")
|
except json.JSONDecodeError:
|
||||||
s_file.truncate(0)
|
pass
|
||||||
s_file.seek(0)
|
with open("/home/pi/Conjurer/hit.playlist", "w", encoding="utf-8") as w_file:
|
||||||
json.dump(priority_list, s_file)
|
try:
|
||||||
create_playlist()
|
for item in priority_list:
|
||||||
|
w_file.write(item)
|
||||||
|
w_file.write("\n")
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def thread_rescan():
|
def thread_rescan():
|
||||||
@@ -313,10 +282,10 @@ def clear_pr_pls():
|
|||||||
|
|
||||||
:return: A JSON response indicating the success of the operation.
|
:return: A JSON response indicating the success of the operation.
|
||||||
"""
|
"""
|
||||||
with open(
|
app.logger.info("CLEARING PLAYLIST")
|
||||||
"/home/pi/Conjurer/priority_queue.playlist", "w", encoding="utf-8"
|
with open('/home/pi/Conjurer/priority_queue.playlist', 'w', encoding='utf-8') as cleared_pl:
|
||||||
) as s_file:
|
cleared_pl.write('')
|
||||||
s_file.truncate(0)
|
|
||||||
return_data = jsonify(isError=False, message="Success", statusCode=200, data=[])
|
return_data = jsonify(isError=False, message="Success", statusCode=200, data=[])
|
||||||
return return_data, 200
|
return return_data, 200
|
||||||
|
|
||||||
|
|||||||
@@ -204,6 +204,13 @@
|
|||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
],
|
],
|
||||||
|
"same plusy\\b": [
|
||||||
|
"Jak na cmentarzu Szefie. Jak na cmentarzu",
|
||||||
|
15.0,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
],
|
||||||
"kld\\b": [
|
"kld\\b": [
|
||||||
"KLD? Mieli tam burdel większy niż u Hammera. Ale o ile Hammer sprzątnął już nawet całkiem nieźle - to tam śmieci wyniosły się same. Uczcijmy ich minutą śmiechu.",
|
"KLD? Mieli tam burdel większy niż u Hammera. Ale o ile Hammer sprzątnął już nawet całkiem nieźle - to tam śmieci wyniosły się same. Uczcijmy ich minutą śmiechu.",
|
||||||
15.0,
|
15.0,
|
||||||
|
|||||||
@@ -239,6 +239,8 @@ def get_item_name(sp, item_type, item_id):
|
|||||||
name = sp.album(album_id=item_id).get("name")
|
name = sp.album(album_id=item_id).get("name")
|
||||||
elif item_type == "track":
|
elif item_type == "track":
|
||||||
name = sp.track(track_id=item_id).get("name")
|
name = sp.track(track_id=item_id).get("name")
|
||||||
|
elif item_type == "artist_top_tracks":
|
||||||
|
name = sp.artist_top_tracks(artist_id=item_id).get("name")
|
||||||
return sanitize(name)
|
return sanitize(name)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user