Skip to content

Commit a499682

Browse files
From now on, Persepolis can recognize YouTube links while checking the clipboard automatically.
1 parent f774fe3 commit a499682

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

persepolis/scripts/mainwindow.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,25 @@ def checkSelectedRow(self):
26062606
# hide video_finder_widget
26072607
self.video_finder_widget.hide()
26082608

2609+
# Check if this link is related to video finder or not
2610+
def checkVideoFinderSupportedSites(self, link):
2611+
# add your favorite site in this list
2612+
# please don't add porn sites!
2613+
supported_sites_list = [
2614+
'youtube.com/watch',
2615+
'aparat.com/v/',
2616+
'vimeo.com/',
2617+
'dailymotion.com/video',
2618+
'https://soundcloud.com/'
2619+
]
2620+
video_finder_supported = False
2621+
for supported_site in supported_sites_list:
2622+
if supported_site in link:
2623+
video_finder_supported = True
2624+
break
2625+
2626+
return video_finder_supported
2627+
26092628
# when user requests calls persepolis with browser plugin,
26102629
# this method is called by CheckingThread.
26112630
def checkPluginCall(self):
@@ -2622,26 +2641,9 @@ def checkPluginCall(self):
26222641
# get maximum of youtube,... link from persepolis_setting
26232642
max_links = int(self.persepolis_setting.value('settings/video_finder/max_links', 3))
26242643

2625-
# add your favorite site in this list
2626-
# please don't add porn sites!
2627-
supported_sites_list = [
2628-
'youtube.com/watch',
2629-
'aparat.com/v/',
2630-
'vimeo.com/',
2631-
'dailymotion.com/video',
2632-
'https://soundcloud.com/'
2633-
]
2634-
26352644
for link in list_of_links:
26362645

2637-
# if link is on of supported_sites_list member then change
2638-
# video_finder_supported to True value.
2639-
video_finder_supported = False
2640-
2641-
for supported_site in supported_sites_list:
2642-
if supported_site in link['link']:
2643-
video_finder_supported = True
2644-
break
2646+
video_finder_supported = self.checkVideoFinderSupportedSites(link['link'])
26452647

26462648
# if link is on of supported_sites_list member, the open video_finder_addlink_window
26472649
if max_links and video_finder_supported:
@@ -4449,7 +4451,12 @@ def importLinksFromClipboard(self, menu=None):
44494451

44504452
# create temp file to save links
44514453
if len(links_list) == 1:
4452-
self.addLinkButtonPressed(button=None)
4454+
video_finder_supported = self.checkVideoFinderSupportedSites(links_list[0])
4455+
4456+
if video_finder_supported is True:
4457+
self.showVideoFinderAddLinkWindow()
4458+
else:
4459+
self.addLinkButtonPressed(button=None)
44534460

44544461
elif len(links_list) > 1:
44554462
temp = tempfile.NamedTemporaryFile(mode="w+", prefix="persepolis")

0 commit comments

Comments
 (0)