Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BitChute] Back-port from yt-dlp and enhance #31019

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Small update, force CI
dirkf authored Feb 4, 2023
commit ab362c8031b3ae63e174a1330133276b01e34f80
13 changes: 6 additions & 7 deletions youtube_dl/extractor/bitchute.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
int_or_none,
merge_dicts,
orderedSet,
strip_or_none,
unified_timestamp,
urlencode_postdata,
urljoin,
@@ -61,7 +60,7 @@ def _list_entries(self, list_id):

def _search_title(self, html, title_id, **kwargs):
return (
strip_or_none(clean_html(get_element_by_id(title_id, html)))
clean_html(get_element_by_id(title_id, html)) or None
or self._og_search_title(html, default=None)
or self._html_search_regex(r'(?s)<title\b[^>]*>.*?</title', html, 'title', **kwargs))

@@ -118,18 +117,18 @@ class BitChuteIE(BitChuteBaseIE):
@staticmethod
def _extract_urls(webpage):
urls = re.finditer(
r'''<(?:script|iframe)\b[^>]+\bsrc\s*=\s*(["'])(?P<url>%s)''' % (BitChuteIE._VALID_URL, ),
r'''<(?:script|iframe)\b[^>]+\bsrc\s*=\s*("|')(?P<url>%s)''' % (BitChuteIE._VALID_URL, ),
webpage)
return (mobj.group('url') for mobj in urls)

def _real_extract(self, url):
video_id = self._match_id(url)

def get_error_title(html):
return strip_or_none(clean_html(get_element_by_class('page-title', html)))
return clean_html(get_element_by_class('page-title', html)) or None

def get_error_text(html):
return strip_or_none(clean_html(get_element_by_id('page-detail', html)))
return clean_html(get_element_by_id('page-detail', html)) or None

webpage, urlh = self._download_webpage_handle(
'https://www.bitchute.com/video/' + video_id, video_id,
@@ -156,7 +155,7 @@ def get_error_text(html):
entries = self._parse_html5_media_entries(
url, webpage, video_id)
if not entries:
error = strip_or_none(clean_html(get_element_by_id('video-title', webpage)))
error = clean_html(get_element_by_id('video-title', webpage)) or None
if error == 'Video Unavailable':
raise GeoRestrictedError(error, expected=True)
error = get_error_title(webpage)
@@ -294,7 +293,7 @@ def _real_extract(self, url):
self._list_entries(playlist_id), playlist_id=playlist_id, playlist_title=title)

description = (
strip_or_none(clean_html(get_element_by_class('description', webpage)))
clean_html(get_element_by_class('description', webpage))
or self._search_description(webpage, None))

return merge_dicts(