Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Add Python function for testing YTDL url support #88

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions sailfish/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -65,39 +65,8 @@ ApplicationWindow {
}

function isUrlSupported(url) {
// TODO: now simply matches url against our own simple list. We should query YTDL itself.
//console.log("testing ytdl support for url " + url)
if (/^https?:\/\/((www|m)\.)?youtube\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/((www|m)\.)?youtu\.be\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/((www)\.)?streamable\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/((www)\.)?livestream\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/my\.mixtape\.moe\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/(.+\.)?twitch.tv\/.+/.test(url)) {
return true;
// } else if (/^https?:\/\/((www)\.)?vimeo.com\/.+/.test(url)) {
// return true;
} else if (/^https?:\/\/(www\.)?gfycat\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/((i|m)\.)?imgur\.com\/.+\.gifv$/.test(url)) {
return true;
} else if (/^https?:\/\/v\.redd\.it\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/(www\.)?pornhub\.com\/view_video\.php.+/.test(url)) {
return true;
} else if (/^https?:\/\/(www\.)?hooktube\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/(www\.)?dailymotion\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/(www\.)?bitchute\.com\/.+/.test(url)) {
return true;
} else {
return false;
}
return call_sync('ytdl_wrapper.isVideoUrlSupported', [url.toString()] )
}

onError: {
Expand Down
9 changes: 9 additions & 0 deletions sailfish/qml/ytdl_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ def retrieveVideoInfo(url):
except youtube_dl.utils.DownloadError as e:
pyotherside.send('fail', ','.join(e.args))

def isVideoUrlSupported(url):
for ie in youtube_dl.list_extractors(False):
if ie.suitable(url):
if not ie.working():
logger.debug('extractor ' + ie + " currently broken")
continue
return True
return False

def downloadVideo(url):
logger.debug('downloadVideo ' + str(url))
# not implemented yet
9 changes: 9 additions & 0 deletions ubuntu-touch/Qml/ytdl_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ def retrieveVideoInfo(url):
except youtube_dl.utils.DownloadError as e:
pyotherside.send('fail', ','.join(e.args))

def isVideoUrlSupported(url):
for ie in youtube_dl.list_extractors(False):
if ie.suitable(url):
if not ie.working():
logger.debug('extractor ' + ie + " currently broken")
continue
return True
return False

def downloadVideo(url):
logger.debug('downloadVideo ' + str(url))
# not implemented yet
33 changes: 1 addition & 32 deletions ubuntu-touch/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -525,39 +525,8 @@ ApplicationWindow {
}

function isUrlSupported(url) {
// TODO: now simply matches url against our own simple list. We should query YTDL itself.
//console.log("testing ytdl support for url " + url)
if (/^https?:\/\/((www|m)\.)?youtube\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/((www|m)\.)?youtu\.be\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/((www)\.)?streamable\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/((www)\.)?livestream\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/my\.mixtape\.moe\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/(.+\.)?twitch.tv\/.+/.test(url)) {
return true;
// } else if (/^https?:\/\/((www)\.)?vimeo.com\/.+/.test(url)) {
// return true;
} else if (/^https?:\/\/(www\.)?gfycat\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/((i|m)\.)?imgur\.com\/.+\.gifv$/.test(url)) {
return true;
} else if (/^https?:\/\/v\.redd\.it\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/(www\.)?pornhub\.com\/view_video\.php.+/.test(url)) {
return true;
} else if (/^https?:\/\/(www\.)?hooktube\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/(www\.)?dailymotion\.com\/.+/.test(url)) {
return true;
} else if (/^https?:\/\/(www\.)?bitchute\.com\/.+/.test(url)) {
return true;
} else {
return false;
}
return call_sync('ytdl_wrapper.isVideoUrlSupported', [url.toString()] )
}

onError: {
Expand Down