73
73
total_downloaded_videos_attempt = 0 # All videos the user tries to download
74
74
logger = setup_logging ()
75
75
76
- # TODO: Fix FFmpeg path
77
- # TODO: Fix FFmpeg install signals
78
- # TODO: Implement error signals for all threading classes
79
- # TODO: Implement data dictionary and basic objects for all threading classes
80
- # TODO: Rework the get_model function using list comprehensions
81
-
82
-
83
76
84
77
class Signals (QObject ):
85
78
"""Signals for the Download class"""
@@ -378,7 +371,7 @@ def run(self):
378
371
" Are you at a university, school or in a public WiFi?" })
379
372
380
373
except Exception as e :
381
- self .website_results . update ({ website : f"Unknown Error: { e } " } )
374
+ self .signals . error_signal . emit ( e )
382
375
383
376
self .signals .internet_check .emit (self .website_results )
384
377
@@ -404,6 +397,7 @@ def run(self):
404
397
405
398
except Exception as e :
406
399
logger .error (f"Could not check for updates. Please report the following error on GitHub: { e } " )
400
+ self .signals .error_signal .emit (e )
407
401
408
402
409
403
class FFMPEGDownload (QRunnable ):
@@ -432,8 +426,9 @@ def delete_dir():
432
426
shutil .rmtree (f"ffmpeg-{ search .group (1 )} -amd64-static" )
433
427
return True
434
428
435
- except AttributeError :
436
- pass
429
+ except AttributeError as e :
430
+ logger .error ("Couldn't find the ffmpeg directories for cleaning them up! This may not be a serious issue, "
431
+ f"please report it anyways: { e } " )
437
432
438
433
return False
439
434
@@ -497,7 +492,7 @@ def run(self):
497
492
else :
498
493
logger .error ("The Regex for finding the FFmpeg version failed. Please report this on GitHub!, Thanks." )
499
494
500
- # TODO
495
+ self . signals . ffmpeg_download_finished . emit ()
501
496
502
497
503
498
class AddToTreeWidget (QRunnable ):
@@ -517,9 +512,9 @@ def __init__(self, iterator, search_limit, data_mode, is_reverse, is_checked, la
517
512
self .directory_system = directory_system
518
513
519
514
def process_video (self , video , index ):
520
- print (f"Requesting processing of video : { video .url } " )
515
+ logger . debug (f"Requesting video processing of: { video .url } " )
521
516
video = check_video (video , delay = self .delay )
522
- print ( type ( video ))
517
+
523
518
try :
524
519
data = load_video_attributes (video , self .data_mode )
525
520
@@ -584,7 +579,6 @@ def run(self):
584
579
self .signals .clear_tree_widget_signal .emit () # Clears the tree widget
585
580
586
581
self .signals .start_undefined_range .emit () # Starts the progressbar, but with a loading animation
587
-
588
582
if self .is_checked :
589
583
index = self .last_index
590
584
start = index
@@ -593,8 +587,6 @@ def run(self):
593
587
else :
594
588
start = 1
595
589
self .last_index = start
596
- print (type (self .iterator ))
597
- print (f"Iterator: { self .iterator } " )
598
590
599
591
try :
600
592
logger .debug (f"Result Limit: { str (self .search_limit )} " )
@@ -966,7 +958,6 @@ def __init__(self, parent=None, start_installation=False, app_name="Porn Fetch")
966
958
967
959
# Threads
968
960
self .install_thread = None
969
- self .thread = None
970
961
self .internet_check_thread = None
971
962
self .update_thread = None
972
963
self .url_thread = None
@@ -975,6 +966,7 @@ def __init__(self, parent=None, start_installation=False, app_name="Porn Fetch")
975
966
self .video_converting_thread = None
976
967
self .post_processing_thread = None
977
968
self .download_tree_thread = None
969
+ self .add_to_tree_widget_thread_ = None
978
970
979
971
# Button groups
980
972
self .group_threading_mode = None
@@ -1533,8 +1525,6 @@ def start_single_video(self):
1533
1525
1534
1526
def start_model (self , url = None ):
1535
1527
"""Starts the model downloads"""
1536
- # TODO: Needs to be refactored using dictionary comprehensions and the shared_functions.py file
1537
-
1538
1528
if isinstance (url , str ):
1539
1529
model = url
1540
1530
@@ -1643,7 +1633,7 @@ def receive_url_result(self, iterator, model_iterator, search_iterator):
1643
1633
def search (self ):
1644
1634
"""Does a simple search for videos without filters on selected website"""
1645
1635
query = self .ui .download_lineedit_search_query .text ()
1646
-
1636
+ logger . debug ( f"Searching with query: { query } " )
1647
1637
if self .ui .download_radio_search_website_pornhub .isChecked ():
1648
1638
videos = Client ().search (query )
1649
1639
@@ -1678,15 +1668,17 @@ def add_to_tree_widget_thread(self, iterator):
1678
1668
is_reverse = self .ui .main_checkbox_tree_show_videos_reversed .isChecked ()
1679
1669
is_checked = self .ui .main_checkbox_tree_do_not_clear_videos .isChecked ()
1680
1670
1681
- self .thread = AddToTreeWidget (iterator = iterator , search_limit = search_limit , data_mode = data_mode ,
1671
+ self .add_to_tree_widget_thread_ = AddToTreeWidget (iterator = iterator , search_limit = search_limit , data_mode = data_mode ,
1682
1672
is_reverse = is_reverse , is_checked = is_checked , last_index = self .last_index ,
1683
1673
directory_system = self .directory_system , delay = self .delay , url = iterator ,
1684
1674
output_path = self .output_path )
1685
- self .thread .signals .text_data_to_tree_widget .connect (self .add_to_tree_widget_signal )
1686
- self .thread .signals .clear_tree_widget_signal .connect (self .clear_tree_widget )
1687
- self .thread .signals .start_undefined_range .connect (self .start_undefined_range )
1688
- self .thread .signals .stop_undefined_range .connect (self .stop_undefined_range )
1675
+ self .add_to_tree_widget_thread_ .signals .text_data_to_tree_widget .connect (self .add_to_tree_widget_signal )
1676
+ self .add_to_tree_widget_thread_ .signals .clear_tree_widget_signal .connect (self .clear_tree_widget )
1677
+ self .add_to_tree_widget_thread_ .signals .start_undefined_range .connect (self .start_undefined_range )
1678
+ self .add_to_tree_widget_thread_ .signals .stop_undefined_range .connect (self .stop_undefined_range )
1679
+ self .add_to_tree_widget_thread_ .signals .error_signal .connect (self .show_error )
1689
1680
self .threadpool .start (self .thread )
1681
+ logger .debug ("Started the thread for adding videos..." )
1690
1682
1691
1683
def add_to_tree_widget_signal (self , data : dict ):
1692
1684
"""
@@ -1733,6 +1725,7 @@ def download_tree_widget(self):
1733
1725
self .download_tree_thread .signals .start_undefined_range .connect (self .start_undefined_range )
1734
1726
self .download_tree_thread .signals .stop_undefined_range .connect (self .stop_undefined_range )
1735
1727
self .download_tree_thread .signals .progress_send_video .connect (self .process_video_thread )
1728
+ self .download_tree_thread .signals .error_signal .connect (self .show_error )
1736
1729
1737
1730
self .threadpool .start (self .download_tree_thread )
1738
1731
@@ -1750,6 +1743,7 @@ def process_video_thread(self, video, data):
1750
1743
self .download_thread .signals .progress_xvideos .connect (self .update_progressbar_xvideos )
1751
1744
self .download_thread .signals .progress_spankbang .connect (self .update_progressbar_spankbang )
1752
1745
self .download_thread .signals .ffmpeg_converting_progress .connect (self .update_converting )
1746
+ self .download_thread .signals .error_signal .connect (self .show_error )
1753
1747
# ADAPTION
1754
1748
self .download_thread .signals .download_completed .connect (self .download_completed )
1755
1749
self .threadpool .start (self .download_thread )
@@ -1771,8 +1765,6 @@ def download_completed(self, data):
1771
1765
self .post_processing_thread .signals .ffmpeg_converting_progress .connect (self .update_converting )
1772
1766
self .post_processing_thread .signals .error_signal .connect (self .show_error )
1773
1767
self .threadpool .start (self .post_processing_thread )
1774
-
1775
- # TODO: Add the post processing into this method
1776
1768
self .semaphore .release ()
1777
1769
1778
1770
def show_error (self , error ):
@@ -1782,9 +1774,6 @@ def show_error(self, error):
1782
1774
{ error } """ )
1783
1775
ui_popup (err )
1784
1776
1785
-
1786
-
1787
-
1788
1777
def reindex (self ):
1789
1778
ascending = self .ui .treeWidget .header ().sortIndicatorOrder () == Qt .SortOrder .AscendingOrder
1790
1779
count = self .ui .treeWidget .topLevelItemCount ()
@@ -1976,8 +1965,6 @@ def update_progressbar_spankbang(self, value, maximum):
1976
1965
1977
1966
# ADAPTION
1978
1967
1979
-
1980
-
1981
1968
def start_undefined_range (self ):
1982
1969
"""This starts the undefined range (loading animation) of the total progressbar"""
1983
1970
self .ui .main_progressbar_total .setRange (0 , 0 )
@@ -2167,12 +2154,14 @@ def check_for_updates(self):
2167
2154
"""Checks for updates in a thread, so that the main UI isn't blocked, until update checks are done"""
2168
2155
self .update_thread = CheckUpdates ()
2169
2156
self .update_thread .signals .result .connect (check_for_updates_result )
2157
+ self .update_thread .signals .error_signal .connect (self .show_error )
2170
2158
self .threadpool .start (self .update_thread )
2171
2159
2172
2160
def check_internet (self ):
2173
2161
"""Checks if the porn sites are accessible"""
2174
2162
self .internet_check_thread = InternetCheck ()
2175
2163
self .internet_check_thread .signals .internet_check .connect (self .internet_check_result )
2164
+ self .internet_check_thread .signals .error_signal .connect (self .show_error )
2176
2165
self .threadpool .start (self .internet_check_thread )
2177
2166
2178
2167
def internet_check_result (self , results : dict ):
0 commit comments