1818# ""
1919class Ui (QtWidgets .QMainWindow , Ui_MainWindow ):
2020
21- file_name = "/%(title)s.%(ext)s"
21+ file_name = "/%(title)s (%(height)sp) .%(ext)s"
2222 queue_path = ""
2323 ydl_opts = {
2424 "format" : "bestaudio/best" ,
25+ "concurrent_fragments" : "2" , # If this is too high youtube might slow down download speeds
2526 "quiet" : True ,
2627 "verbose" : False ,
2728 "outtmpl" : queue_path ,
2829 "postprocessors" : [{
2930 "key" : "FFmpegExtractAudio" ,
3031 "preferredcodec" : "mp3" ,
31- "preferredquality" : "192 " ,
32+ "preferredquality" : "320 " ,
3233 }],
3334 "ffmpeg_location" : "YtExtraFiles" ,
3435 "ignoreerrors" : True ,
@@ -557,6 +558,7 @@ def reset_folder_save(self):
557558
558559 # ""
559560 def remove_pp (self ):
561+ self .file_name = "/%(title)s (%(height)sp).%(ext)s"
560562 self .ydl_opts ["outtmpl" ] = self .queue_path + self .file_name
561563 try :
562564 del self .ydl_opts ["postprocessors" ]
@@ -568,39 +570,42 @@ def remove_pp(self):
568570 def change_quality (self , s ):
569571 self .qualities_index = self .qualities_box .currentIndex ()
570572 if s == 0 :
571- self .ydl_opts ["format" ] = 'bestvideo[ext=mp4] +bestaudio[ext=m4a]/best[ext=mp4] /best'
573+ self .ydl_opts ["format" ] = 'bestvideo+bestaudio/best'
572574 self .remove_pp ()
573575
574576 elif s == 1 :
575- self .ydl_opts [
576- "format" ] = 'bestvideo[height<=?1080][ext=mp4]+bestaudio[ext=m4a]/best[height<=?1080][ext=mp4]'
577+ self .ydl_opts ["format" ] = 'bestvideo*[height<=1080][ext=mp4]+bestaudio/best[height<=1080]'
577578 self .remove_pp ()
578579
579580 elif s == 2 :
580- self .ydl_opts ["format" ] = 'bestvideo[height<=? 720][ext=mp4]+bestaudio[ext=m4a] /best[height<=? 720][ext=mp4 ]'
581+ self .ydl_opts ["format" ] = 'bestvideo* [height<=720][ext=mp4]+bestaudio/best[height<=720]'
581582 self .remove_pp ()
582583
583584 elif s == 3 :
584- self .ydl_opts ["format" ] = 'bestvideo[height<=? 480][ext=mp4]+bestaudio[ext=m4a] /best[height<=? 480][ext=mp4 ]'
585+ self .ydl_opts ["format" ] = 'bestvideo* [height<=480][ext=mp4]+bestaudio/best[height<=480]'
585586 self .remove_pp ()
586587
587588 elif s == 4 :
588- self .ydl_opts ["format" ] = 'bestvideo[height<=? 360][ext=mp4]+bestaudio[ext=m4a] /best[height<=? 360][ext=mp4 ]'
589+ self .ydl_opts ["format" ] = 'bestvideo* [height<=360][ext=mp4]+bestaudio/best[height<=360]'
589590 self .remove_pp ()
590591
591592 elif s == 5 :
592- self .ydl_opts ["format" ] = "worst"
593+ self .ydl_opts ["format" ] = "worst/worstvideo+worstaudio "
593594 self .remove_pp ()
594595
595- elif s == 6 :
596+ if s == 6 :
597+ self .file_name = "/%(title)s.%(ext)s"
596598 self .ydl_opts ["format" ] = "bestaudio/best"
597599 self .ydl_opts ["postprocessors" ] = [{
598600 "key" : "FFmpegExtractAudio" ,
599601 "preferredcodec" : "mp3" ,
600- "preferredquality" : "192 " ,
602+ "preferredquality" : "320 " ,
601603 }]
602604
603605
606+
607+
608+
604609if __name__ == '__main__' :
605610 import sys
606611 app = QtWidgets .QApplication (sys .argv )
0 commit comments