17
17
from mmdl import MusicDownloader
18
18
from .ask import asker
19
19
from rich .console import Console
20
+ from .utils import *
20
21
import questionary
21
22
console = Console ()
22
23
from click_help_colors import HelpColorsGroup , HelpColorsCommand
@@ -50,23 +51,15 @@ def go(verbose, debug):
50
51
# Go Command
51
52
> Easy way to download songs. Uses inputs/inquirer. (Simply run 'mmdl go')
52
53
"""
54
+ print_logo ()
53
55
54
56
if debug :
55
57
console .log ("Verbose: " , verbose )
56
58
console .log ("Debug: " , debug )
57
59
58
- console .print ("""\b [red]
59
- _ _
60
- | | |
61
- _ __ ___ _ __ ___ __| | |
62
- | '_ ` _ \| '_ ` _ \ / _` | |
63
- | | | | | | | | | | | (_| | | [/]by techboy-coder[red]
64
- |_| |_| |_|_| |_| |_|\__,_|_| [/]find me on https://github.com/techboy-coder
65
-
66
- [green]mmdl [Mega Music Downloader] - A tool to easily download music.[/green]
67
- """ )
60
+
68
61
song_names = asker ()
69
- console . print ( " \n [cyan]> [/] Total number of songs: %s. \n " % ( len (song_names ) ))
62
+ num_of_songs_printer ( len (song_names ))
70
63
# List, verbose, debug
71
64
MusicDownloader (song_names , verbose , debug ).download_songs ()
72
65
@@ -114,19 +107,11 @@ def file(file, seperator, verbose, debug):
114
107
console .log ("Verbose: " , verbose )
115
108
console .log ("Debug: " , debug )
116
109
117
- console .print ("""\b [red]
118
- _ _
119
- | | |
120
- _ __ ___ _ __ ___ __| | |
121
- | '_ ` _ \| '_ ` _ \ / _` | |
122
- | | | | | | | | | | | (_| | | [/]by techboy-coder[red]
123
- |_| |_| |_|_| |_| |_|\__,_|_| [/]find me on https://github.com/techboy-coder
124
-
125
- [green]mmdl [Mega Music Downloader] - A tool to easily download music.[/green]
126
- """ )
127
- console .print ("\n [cyan]> [/] Total number of songs: %s. \n " % (len (songs )))
128
- if not questionary .confirm ("Do you want to continue" ).ask ():
129
- quit ()
110
+ print_logo ()
111
+
112
+ num_of_songs_printer (len (songs ))
113
+
114
+ wanna_continue ()
130
115
# file, verbose, debug
131
116
MusicDownloader (songs , verbose , debug ).download_songs ()
132
117
return
@@ -153,14 +138,14 @@ def list(songs, verbose, debug, ask):
153
138
"""
154
139
if ask :
155
140
console .print ("[cyan][>][/] We'll be manually asking you for songs." )
156
- songs_list = questionary .text ("Write all songs search terms (comma seperated)" ).ask ()
141
+ songs_list = questionary .text ("Write all songs search terms (comma seperated): " ).ask ()
157
142
if not songs_list :
158
143
quit ()
159
144
songs_list = songs_list .split ("," )
160
145
else :
161
146
if len (songs ) < 1 :
162
147
# console.print("[cyan][-][/] You didn't specify any songs. So we'll be manually asking them to you.")
163
- songs_list = questionary .text ("Write all songs search terms (comma seperated)" ).ask ()
148
+ songs_list = questionary .text ("Write all songs search terms (comma seperated): " ).ask ()
164
149
if not songs_list :
165
150
quit ()
166
151
songs_list = songs_list .split ("," )
@@ -174,17 +159,8 @@ def list(songs, verbose, debug, ask):
174
159
console .log ("Verbose: " , verbose )
175
160
console .log ("Debug: " , debug )
176
161
177
- console .print ("""\b [red]
178
- _ _
179
- | | |
180
- _ __ ___ _ __ ___ __| | |
181
- | '_ ` _ \| '_ ` _ \ / _` | |
182
- | | | | | | | | | | | (_| | | [/]by techboy-coder[red]
183
- |_| |_| |_|_| |_| |_|\__,_|_| [/]find me on https://github.com/techboy-coder
184
-
185
- [green]mmdl [Mega Music Downloader] - A tool to easily download music.[/green]
186
- """ )
187
- console .print ("\n [cyan]> [/] Total number of songs: %s. \n " % (len (songs_list )))
162
+ print_logo ()
163
+ num_of_songs_printer (len (songs_list ))
188
164
# file, verbose, debug
189
165
MusicDownloader (songs_list , verbose , debug ).download_songs ()
190
166
return
@@ -209,66 +185,48 @@ def ytmusic(file, verbose, debug, ask):
209
185
"""
210
186
if not ask and not file :
211
187
ask = True
212
- if ask :
213
- console .print ("[cyan][>][/] We'll be manually asking you for the file location." )
214
- console .print ("""
188
+
189
+ guide = """
215
190
[bold red]YT-Music[/bold red].
216
191
- Go to your YTMusic liked songs playlist (https://music.youtube.com/playlist?list=LM)
217
192
- Make sure you are logged in
218
193
- Press Ctrl/Cmd + Shift + i and open the dev tools
219
194
- Keep scrolling down until you reach the end of your playlist (Songs will stop loading)
220
195
- Copy the all the html markup
221
196
- Create a text file and paste the html into it.
222
- """ )
223
- if not questionary .confirm ("Only continue if you have done the task." ).ask ():
224
- quit ()
197
+ """
198
+
199
+ if ask :
200
+ console .print ("[cyan][>][/] We'll be manually asking you for the file location." )
201
+ console .print (guide )
202
+ wanna_continue ("Only continue if you have done the task." )
203
+
225
204
file = questionary .path ("Where is that file located?" ).ask ()
226
205
with open (file , "r" , encoding = "utf-8" ) as f :
227
206
data = f .read ()
228
- h = fromstring (data )
229
- sel = CSSSelector ("yt-formatted-string.title.style-scope.ytmusic-responsive-list-item-renderer.complex-string > a.yt-simple-endpoint.style-scope.yt-formatted-string" )
230
- songs_list = [e .text for e in sel (h )]
231
- if not songs_list [0 ]:
232
- console .log ("[red][-] Hmm. No songs could be parsed from html. Did you select the correct HTML? If you see a error please make a bug report. Thanks!" )
233
- quit ()
207
+
234
208
if not ask :
235
209
if not file :
236
210
console .log ("[red][-] You need to enter the file location or add the -a flag." )
237
211
quit ()
238
212
data = file .read ()
239
- h = fromstring (data )
240
- sel = CSSSelector ("yt-formatted-string.title.style-scope.ytmusic-responsive-list-item-renderer.complex-string > a.yt-simple-endpoint.style-scope.yt-formatted-string" )
241
- songs_list = [e .text for e in sel (h )]
242
- if not songs_list [0 ]:
243
- console .log ("[red][-] Hmm. No songs could be parsed from html. Did you select the correct HTML? If you see a error please make a bug report. Thanks!" )
244
- console .print ("""
245
- [bold red]YT-Music[/bold red].
246
- - Go to your YTMusic liked songs playlist (https://music.youtube.com/playlist?list=LM)
247
- - Make sure you are logged in
248
- - Press Ctrl/Cmd + Shift + i and open the dev tools
249
- - Keep scrolling down until you reach the end of your playlist (Songs will stop loading)
250
- - Copy the all the html markup
251
- - Create a text file and paste the html into it.
252
- """ )
213
+
214
+
215
+ h = fromstring (data )
216
+ sel = CSSSelector ("yt-formatted-string.title.style-scope.ytmusic-responsive-list-item-renderer.complex-string > a.yt-simple-endpoint.style-scope.yt-formatted-string" )
217
+ songs_list = [e .text for e in sel (h )]
218
+ if not songs_list [0 ]:
219
+ console .log ("[red][-] Hmm. No songs could be parsed from html. Did you select the correct HTML? If you see a error please make a bug report. Thanks!" )
220
+ console .print (guide )
253
221
254
222
255
223
if debug :
256
224
console .log ("Songs: " , str (songs_list ))
257
225
console .log ("Verbose: " , verbose )
258
226
console .log ("Debug: " , debug )
259
- console .print ("""\b [red]
260
- _ _
261
- | | |
262
- _ __ ___ _ __ ___ __| | |
263
- | '_ ` _ \| '_ ` _ \ / _` | |
264
- | | | | | | | | | | | (_| | | [/]by techboy-coder[red]
265
- |_| |_| |_|_| |_| |_|\__,_|_| [/]find me on https://github.com/techboy-coder
266
-
267
- [green]mmdl [Mega Music Downloader] - A tool to easily download music.[/green]
268
- """ )
269
- console .print ("\n [cyan]> [/] Total number of songs: %s. \n " % (len (songs_list )))
270
- if not questionary .confirm ("Do you want to continue" ).ask ():
271
- quit ()
227
+ print_logo ()
228
+ num_of_songs_printer (len (songs_list ))
229
+ wanna_continue ()
272
230
# file, verbose, debug
273
231
MusicDownloader (songs_list , verbose , debug ).download_songs ()
274
232
return
@@ -300,16 +258,7 @@ def single(song, verbose, debug):
300
258
console .log ("Verbose: " , verbose )
301
259
console .log ("Debug: " , debug )
302
260
303
- console .print ("""\b [red]
304
- _ _
305
- | | |
306
- _ __ ___ _ __ ___ __| | |
307
- | '_ ` _ \| '_ ` _ \ / _` | |
308
- | | | | | | | | | | | (_| | | [/]by techboy-coder[red]
309
- |_| |_| |_|_| |_| |_|\__,_|_| [/]find me on https://github.com/techboy-coder
310
-
311
- [green]mmdl [Mega Music Downloader] - A tool to easily download music.[/green]
312
- """ )
261
+ print_logo ()
313
262
songs = [song ]
314
263
console .print ("\n [cyan]> [/] Song: %s. \n " % (song ))
315
264
# file, verbose, debug
0 commit comments