Spaces:
Sleeping
Sleeping
CaesarCloudSync commited on
Commit ·
47411bd
1
Parent(s): 9ef5372
add songs
Browse files- __pycache__/caesarmusic.cpython-310.pyc +0 -0
- caesarmusic.py +24 -18
__pycache__/caesarmusic.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/caesarmusic.cpython-310.pyc and b/__pycache__/caesarmusic.cpython-310.pyc differ
|
|
|
caesarmusic.py
CHANGED
|
@@ -55,24 +55,30 @@ class CaesarMusic:
|
|
| 55 |
if self.first_time_running == True:
|
| 56 |
#time.sleep(40)
|
| 57 |
self.first_time_running = False
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
return new_file#yt.title
|
| 77 |
except (FileExistsError,Exception) as fex:
|
| 78 |
print(type(fex),fex)
|
|
|
|
| 55 |
if self.first_time_running == True:
|
| 56 |
#time.sleep(40)
|
| 57 |
self.first_time_running = False
|
| 58 |
+
try:
|
| 59 |
+
print('Downloading : {} with url : {}'.format(yt.title, yt.watch_url))
|
| 60 |
+
|
| 61 |
+
# extract only audio
|
| 62 |
+
video = yt.streams.filter(only_audio=True).first()
|
| 63 |
+
|
| 64 |
+
# check for destination to save file
|
| 65 |
+
#print("Enter the destination (leave blank for current directory)")
|
| 66 |
+
|
| 67 |
+
# download the file
|
| 68 |
+
out_file = video.download(output_path=DOWNLOAD_DIR)
|
| 69 |
+
|
| 70 |
+
# save the file
|
| 71 |
+
base, ext = os.path.splitext(out_file)
|
| 72 |
+
new_file = base + '.mp3'
|
| 73 |
+
os.rename(out_file, new_file)
|
| 74 |
+
|
| 75 |
+
# result of success
|
| 76 |
+
#print(yt.title + " has been successfully downloaded.")
|
| 77 |
+
except RuntimeError as rex:
|
| 78 |
+
print(rex)
|
| 79 |
+
self.clean_up_dir(download_dir,"mp3")
|
| 80 |
+
self.clean_up_dir(download_dir,"mp4")
|
| 81 |
+
pass
|
| 82 |
return new_file#yt.title
|
| 83 |
except (FileExistsError,Exception) as fex:
|
| 84 |
print(type(fex),fex)
|