mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-08-22 22:34:01 -07:00
RedGIFs patches
This commit is contained in:
parent
3472227074
commit
289b1da512
5 changed files with 93 additions and 42 deletions
17
Makefile
17
Makefile
|
@ -1,3 +1,6 @@
|
||||||
|
# Also edit in youtube_dl/version.py
|
||||||
|
VERSION = 2022.02.17
|
||||||
|
|
||||||
all: youtube-dl README.md CONTRIBUTING.md README.txt youtube-dl.1 youtube-dl.bash-completion youtube-dl.zsh youtube-dl.fish supportedsites
|
all: youtube-dl README.md CONTRIBUTING.md README.txt youtube-dl.1 youtube-dl.bash-completion youtube-dl.zsh youtube-dl.fish supportedsites
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -37,6 +40,9 @@ test:
|
||||||
nosetests --verbose test
|
nosetests --verbose test
|
||||||
$(MAKE) codetest
|
$(MAKE) codetest
|
||||||
|
|
||||||
|
test-redgifs:
|
||||||
|
python3 -m youtube_dl -jq 'https://xhamster4.com/videos/izzy-bell-creampie-pussy-xhpwA7S'
|
||||||
|
|
||||||
ot: offlinetest
|
ot: offlinetest
|
||||||
|
|
||||||
# Keep this list in sync with devscripts/run_tests.sh
|
# Keep this list in sync with devscripts/run_tests.sh
|
||||||
|
@ -133,3 +139,14 @@ youtube-dl.tar.gz: youtube-dl README.md README.txt youtube-dl.1 youtube-dl.bash-
|
||||||
Makefile MANIFEST.in youtube-dl.1 youtube-dl.bash-completion \
|
Makefile MANIFEST.in youtube-dl.1 youtube-dl.bash-completion \
|
||||||
youtube-dl.zsh youtube-dl.fish setup.py setup.cfg \
|
youtube-dl.zsh youtube-dl.fish setup.py setup.cfg \
|
||||||
youtube-dl
|
youtube-dl
|
||||||
|
|
||||||
|
build:
|
||||||
|
rm -f dist/*.whl
|
||||||
|
VERSION=$(VERSION)_redgifs python3 setup.py bdist_wheel
|
||||||
|
ls -ldh dist/youtube_dl-$(VERSION)_redgifs-py2.py3-none-any.whl
|
||||||
|
|
||||||
|
release: build
|
||||||
|
-gh release create v$(VERSION) --title "v$(VERSION)" --notes "Fixes to extractors, probably."
|
||||||
|
gh release upload v$(VERSION) dist/youtube_dl-$(VERSION)_redgifs-py2.py3-none-any.whl
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
@ -66,46 +67,7 @@ class RedTubeIE(InfoExtractor):
|
||||||
webpage, 'title', group='title',
|
webpage, 'title', group='title',
|
||||||
default=None) or self._og_search_title(webpage)
|
default=None) or self._og_search_title(webpage)
|
||||||
|
|
||||||
formats = []
|
formats = self._get_formats(webpage, video_id)
|
||||||
sources = self._parse_json(
|
|
||||||
self._search_regex(
|
|
||||||
r'sources\s*:\s*({.+?})', webpage, 'source', default='{}'),
|
|
||||||
video_id, fatal=False)
|
|
||||||
if sources and isinstance(sources, dict):
|
|
||||||
for format_id, format_url in sources.items():
|
|
||||||
if format_url:
|
|
||||||
formats.append({
|
|
||||||
'url': format_url,
|
|
||||||
'format_id': format_id,
|
|
||||||
'height': int_or_none(format_id),
|
|
||||||
})
|
|
||||||
medias = self._parse_json(
|
|
||||||
self._search_regex(
|
|
||||||
r'mediaDefinition["\']?\s*:\s*(\[.+?}\s*\])', webpage,
|
|
||||||
'media definitions', default='{}'),
|
|
||||||
video_id, fatal=False)
|
|
||||||
if medias and isinstance(medias, list):
|
|
||||||
for media in medias:
|
|
||||||
format_url = url_or_none(media.get('videoUrl'))
|
|
||||||
if not format_url:
|
|
||||||
continue
|
|
||||||
if media.get('format') == 'hls' or determine_ext(format_url) == 'm3u8':
|
|
||||||
formats.extend(self._extract_m3u8_formats(
|
|
||||||
format_url, video_id, 'mp4',
|
|
||||||
entry_protocol='m3u8_native', m3u8_id='hls',
|
|
||||||
fatal=False))
|
|
||||||
continue
|
|
||||||
format_id = media.get('quality')
|
|
||||||
formats.append({
|
|
||||||
'url': format_url,
|
|
||||||
'format_id': format_id,
|
|
||||||
'height': int_or_none(format_id),
|
|
||||||
})
|
|
||||||
if not formats:
|
|
||||||
video_url = self._html_search_regex(
|
|
||||||
r'<source src="(.+?)" type="video/mp4">', webpage, 'video URL')
|
|
||||||
formats.append({'url': video_url})
|
|
||||||
self._sort_formats(formats)
|
|
||||||
|
|
||||||
thumbnail = self._og_search_thumbnail(webpage)
|
thumbnail = self._og_search_thumbnail(webpage)
|
||||||
upload_date = unified_strdate(self._search_regex(
|
upload_date = unified_strdate(self._search_regex(
|
||||||
|
@ -134,3 +96,51 @@ class RedTubeIE(InfoExtractor):
|
||||||
'age_limit': age_limit,
|
'age_limit': age_limit,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def _get_formats(self, webpage, video_id):
|
||||||
|
formats = []
|
||||||
|
|
||||||
|
matches = re.findall(r'\{.+?\}', webpage)
|
||||||
|
if matches is not None:
|
||||||
|
for match in matches:
|
||||||
|
try:
|
||||||
|
match = json.loads(match)
|
||||||
|
if 'videoUrl' in match:
|
||||||
|
url = match['videoUrl']
|
||||||
|
if url.startswith('https://www.redtube.com/media/mp4?'):
|
||||||
|
self._add_formats(formats, url, 'mp4', video_id)
|
||||||
|
elif url.startswith('https://www.redtube.com/media/hls?'):
|
||||||
|
self._add_formats(formats, url, 'hls', video_id)
|
||||||
|
except json.decoder.JSONDecodeError as e:
|
||||||
|
pass # print(e)
|
||||||
|
|
||||||
|
self._sort_formats(formats)
|
||||||
|
return formats
|
||||||
|
|
||||||
|
def _add_formats(self, formats, url, codec, video_id):
|
||||||
|
raw_meta = self._download_webpage(url, video_id)
|
||||||
|
meta = json.loads(raw_meta)
|
||||||
|
|
||||||
|
for stream in meta:
|
||||||
|
quality = stream['quality']
|
||||||
|
if isinstance(quality, list):
|
||||||
|
quality = quality[0]
|
||||||
|
|
||||||
|
format = {
|
||||||
|
'url': stream['videoUrl'],
|
||||||
|
'format_id': '%s-%s' % (quality, codec),
|
||||||
|
'height': int(quality),
|
||||||
|
}
|
||||||
|
|
||||||
|
mobj = re.search(r'(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+', format['url'])
|
||||||
|
if mobj:
|
||||||
|
height = int(mobj.group('height'))
|
||||||
|
bitrate = int(mobj.group('bitrate'))
|
||||||
|
format.update({
|
||||||
|
'height': height,
|
||||||
|
'tbr': bitrate,
|
||||||
|
})
|
||||||
|
|
||||||
|
formats.append(format)
|
||||||
|
|
||||||
|
return formats
|
||||||
|
|
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import re
|
import re
|
||||||
|
import json
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_str
|
from ..compat import compat_str
|
||||||
|
@ -137,7 +138,7 @@ class XHamsterIE(InfoExtractor):
|
||||||
|
|
||||||
def get_height(s):
|
def get_height(s):
|
||||||
return int_or_none(self._search_regex(
|
return int_or_none(self._search_regex(
|
||||||
r'^(\d+)[pP]', s, 'height', default=None))
|
r'^(\d+)[pP]', s, 'height', default=480))
|
||||||
|
|
||||||
initials = self._parse_json(
|
initials = self._parse_json(
|
||||||
self._search_regex(
|
self._search_regex(
|
||||||
|
|
|
@ -182,3 +182,26 @@ class YouPornIE(InfoExtractor):
|
||||||
'age_limit': age_limit,
|
'age_limit': age_limit,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_formats(self, meta):
|
||||||
|
formats = []
|
||||||
|
|
||||||
|
for item in meta:
|
||||||
|
format = {
|
||||||
|
'url': item['videoUrl'],
|
||||||
|
'format_id': '%s-%s' % (item['quality'], item['codec']),
|
||||||
|
'height': int(item['quality']),
|
||||||
|
}
|
||||||
|
|
||||||
|
mobj = re.search(r'(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+', item['videoUrl'])
|
||||||
|
if mobj:
|
||||||
|
height = int(mobj.group('height'))
|
||||||
|
bitrate = int(mobj.group('bitrate'))
|
||||||
|
format.update({
|
||||||
|
'height': height,
|
||||||
|
'tbr': bitrate,
|
||||||
|
})
|
||||||
|
|
||||||
|
formats.append(format)
|
||||||
|
|
||||||
|
return formats
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__version__ = '2021.12.17'
|
__version__ = '2022.02.17-redgifs'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue