1717from mmdl import MusicDownloader
1818from .ask import asker
1919from rich .console import Console
20+ from .utils import *
2021import questionary
2122console = Console ()
2223from click_help_colors import HelpColorsGroup , HelpColorsCommand
@@ -50,23 +51,15 @@ def go(verbose, debug):
5051 # Go Command
5152 > Easy way to download songs. Uses inputs/inquirer. (Simply run 'mmdl go')
5253 """
54+ print_logo ()
5355
5456 if debug :
5557 console .log ("Verbose: " , verbose )
5658 console .log ("Debug: " , debug )
5759
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+
6861 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 ))
7063 # List, verbose, debug
7164 MusicDownloader (song_names , verbose , debug ).download_songs ()
7265
@@ -114,19 +107,11 @@ def file(file, seperator, verbose, debug):
114107 console .log ("Verbose: " , verbose )
115108 console .log ("Debug: " , debug )
116109
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 ()
130115 # file, verbose, debug
131116 MusicDownloader (songs , verbose , debug ).download_songs ()
132117 return
@@ -153,14 +138,14 @@ def list(songs, verbose, debug, ask):
153138 """
154139 if ask :
155140 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 ()
157142 if not songs_list :
158143 quit ()
159144 songs_list = songs_list .split ("," )
160145 else :
161146 if len (songs ) < 1 :
162147 # 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 ()
164149 if not songs_list :
165150 quit ()
166151 songs_list = songs_list .split ("," )
@@ -174,17 +159,8 @@ def list(songs, verbose, debug, ask):
174159 console .log ("Verbose: " , verbose )
175160 console .log ("Debug: " , debug )
176161
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 ))
188164 # file, verbose, debug
189165 MusicDownloader (songs_list , verbose , debug ).download_songs ()
190166 return
@@ -209,66 +185,48 @@ def ytmusic(file, verbose, debug, ask):
209185 """
210186 if not ask and not file :
211187 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 = """
215190[bold red]YT-Music[/bold red].
216191- Go to your YTMusic liked songs playlist (https://music.youtube.com/playlist?list=LM)
217192- Make sure you are logged in
218193- Press Ctrl/Cmd + Shift + i and open the dev tools
219194- Keep scrolling down until you reach the end of your playlist (Songs will stop loading)
220195- Copy the all the html markup
221196- 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+
225204 file = questionary .path ("Where is that file located?" ).ask ()
226205 with open (file , "r" , encoding = "utf-8" ) as f :
227206 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+
234208 if not ask :
235209 if not file :
236210 console .log ("[red][-] You need to enter the file location or add the -a flag." )
237211 quit ()
238212 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 )
253221
254222
255223 if debug :
256224 console .log ("Songs: " , str (songs_list ))
257225 console .log ("Verbose: " , verbose )
258226 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 ()
272230 # file, verbose, debug
273231 MusicDownloader (songs_list , verbose , debug ).download_songs ()
274232 return
@@ -300,16 +258,7 @@ def single(song, verbose, debug):
300258 console .log ("Verbose: " , verbose )
301259 console .log ("Debug: " , debug )
302260
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 ()
313262 songs = [song ]
314263 console .print ("\n [cyan]> [/] Song: %s. \n " % (song ))
315264 # file, verbose, debug
0 commit comments