@@ -262,6 +262,7 @@ class Signals(QObject):
262
262
263
263
progress_video = Signal (int , int , int )
264
264
progress_video_range = Signal (int , int )
265
+ progress_video_converting = Signal (int , int )
265
266
266
267
error_signal = Signal (object )
267
268
@@ -704,13 +705,16 @@ def __init__(self, video, video_id):
704
705
self .last_update_time = 0
705
706
self ._range_emitted = False
706
707
707
- def generic_callback (self , pos , total , video_source ):
708
+ def callback_remux (self , pos , total ):
709
+ self .signals .progress_video_converting .emit (pos , total )
710
+
711
+ def generic_callback (self , pos , total , video_source = "general" ):
708
712
"""Generic callback function to emit progress signals with rate limiting."""
709
713
current_time = time .time ()
710
714
if self .stop_flag .is_set ():
711
715
return
712
716
# Emit signal for individual progress
713
- if video_source == "hqporner" or video_source == "eporner " :
717
+ if video_source == "raw " :
714
718
715
719
# Check if the current time is at least 0.5 seconds greater than the last update time
716
720
if current_time - self .last_update_time < 0.5 :
@@ -728,7 +732,7 @@ def generic_callback(self, pos, total, video_source):
728
732
729
733
self .signals .progress_video .emit (self .video_id , pos , total ) # Although we don't use total, we need to accept it
730
734
# Update total progress only if the video source uses segments
731
- if video_source not in [ 'hqporner' , 'eporner' ] :
735
+ if video_source == "general" :
732
736
self .update_total_progress ()
733
737
734
738
# Update the last update time to the current time
@@ -763,45 +767,30 @@ def run(self):
763
767
self .signals .total_progress_range .emit (total_segments )
764
768
765
769
# We need to specify the sources, so that it knows which individual progressbar to use
766
- if isinstance (self .video , shared_functions .hq_Video ):
767
- video_source = "hqporner "
770
+ if isinstance (self .video , shared_functions .hq_Video ) or isinstance ( self . video , shared_functions . ep_Video ) :
771
+ video_source = "raw "
768
772
try :
769
773
self .video .download (quality = self .quality , path = self .output_path , no_title = True ,
770
774
callback = lambda pos , total : self .generic_callback (pos , total , video_source ))
771
775
772
776
except Exception :
773
777
error = traceback .format_exc ()
774
- handle_error_gracefully (data = self .consistent_data , self = self , error_message = f"An error happened while downloading a video from HQPorner: { error } " , needs_network_log = True )
775
-
776
- elif isinstance (self .video , shared_functions .ep_Video ):
777
- video_source = "eporner"
778
- try :
779
- self .video .download (quality = self .quality , path = self .output_path , no_title = True ,
780
- callback = lambda pos , total : self .generic_callback (pos , total , video_source ))
781
-
782
- except Exception :
783
- error = traceback .format_exc ()
784
- handle_error_gracefully (data = self .consistent_data , self = self , error_message = f"An error happened while downloading a video from EPorner: { error } " , needs_network_log = True )
785
-
778
+ handle_error_gracefully (data = self .consistent_data , self = self , error_message = f"An error happened while downloading a video from HQPorner / EPorner: { error } " , needs_network_log = True )
786
779
787
- else : # Assuming 'Video' is the class for Pornhub
788
- path = self .output_path
780
+ elif isinstance (self .video , shared_functions .ph_Video ): # Assuming 'Video' is the class for Pornhub
789
781
video_source = "general"
790
782
self .logger .debug ("Starting the Download!" )
791
- try :
792
- self .video .download (downloader = str (self .threading_mode ), path = path , quality = self .quality , remux = True ,
793
- display = lambda pos , total : self .generic_callback (pos , total , video_source ))
794
-
795
- except TypeError :
796
- try :
797
- self .video .download (downloader = str (self .threading_mode ), path = path , quality = self .quality , remux = True , no_title = True ,
798
- callback = lambda pos , total : self .generic_callback (pos , total , video_source ))
783
+ self .video .download (downloader = str (self .threading_mode ), path = self .output_path , quality = self .quality , remux = True , display_remux = self .callback_remux ,
784
+ display = lambda pos , total : self .generic_callback (pos , total ))
799
785
800
- except Exception :
801
- error = traceback .format_exc ()
802
- error = f"An error occurred when trying to download video: { error } . This will be reported!"
803
- handle_error_gracefully (self , data = video_data .consistent_data , error_message = error , needs_network_log = True )
786
+ else :
787
+ self .video .download (downloader = str (self .threading_mode ), path = self .output_path , callback_remux = self .callback_remux , no_title = True ,
788
+ quality = self .quality , remux = True , callback = lambda pos , total : self .generic_callback (pos , total ))
804
789
790
+ except Exception :
791
+ error = traceback .format_exc ()
792
+ error = f"An error occurred when trying to download video: { error } . This will be reported!"
793
+ handle_error_gracefully (self , data = video_data .consistent_data , error_message = error , needs_network_log = True )
805
794
806
795
finally :
807
796
if self .consistent_data .get ("write_metadata" ):
@@ -966,6 +955,7 @@ def __init__(self, parent=None):
966
955
class PornFetch (QMainWindow ):
967
956
def __init__ (self , parent = None ):
968
957
super ().__init__ (parent )
958
+ self .last_update_time = time .time ()
969
959
self .last_thumbnail_change = time .time ()
970
960
self .stylesheets = None
971
961
self ._pixmap_item = None
@@ -2077,6 +2067,7 @@ def process_video_thread(self, video, video_id):
2077
2067
"""Checks which of the three types of threading the user selected and handles them."""
2078
2068
self .create_video_progressbar (video_id = video_id , title = video .title )
2079
2069
self .download_thread = DownloadThread (video = video , video_id = video_id )
2070
+ self .download_thread .signals .progress_video_converting .connect (self .progress_video_remuxing )
2080
2071
self .download_thread .signals .progress_video .connect (self .update_video_progressbar )
2081
2072
self .download_thread .signals .progress_video_range .connect (self .set_video_progress_range )
2082
2073
self .download_thread .signals .total_progress_range .connect (self .update_total_progressbar_range )
@@ -2094,6 +2085,9 @@ def download_completed(self, video_id):
2094
2085
self .ui .progress_lineedit_download_info .setText (
2095
2086
f"Downloaded: { total_downloaded_videos } video(s) this session." )
2096
2087
self .ui .main_progressbar_total .setMaximum (100 )
2088
+ self .ui .main_progressbar_total .setValue (0 )
2089
+ self .ui .main_progressbar_converting .setMaximum (100 )
2090
+ self .ui .main_progressbar_converting .setValue (0 )
2097
2091
video_data .clean_dict (video_id )
2098
2092
self .semaphore .release ()
2099
2093
widgets = self .progress_widgets .pop (video_id , None )
@@ -2269,6 +2263,15 @@ def set_video_progress_range(self, video_id, maximum):
2269
2263
# optional: reset to zero if you like
2270
2264
bar .setValue (0 )
2271
2265
2266
+ def progress_video_remuxing (self , pos , total ):
2267
+ """Updates the progress when the video gets remuxed"""
2268
+ if time .time () - self .last_thumbnail_change < 0.3 :
2269
+ return
2270
+
2271
+ self .ui .main_progressbar_converting .setMaximum (total )
2272
+ self .ui .main_progressbar_converting .setValue (pos )
2273
+ self .last_update_time = time .time ()
2274
+
2272
2275
def update_video_progressbar (self , video_id , pos , maximum ):
2273
2276
"""Fired repeatedly—only updates the current value."""
2274
2277
widget_set = self .progress_widgets .get (video_id )
0 commit comments