diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index c1a6ea2..65f2358 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -34,6 +34,7 @@ jobs: yt_dlp/extractor/commonmistakes.py yt_dlp/extractor/commonprotocols.py yt_dlp/extractor/extractors.py + yt_dlp/extractor/generic.py yt_dlp/extractor/openload.py yt_dlp/extractor/tver.py @@ -41,7 +42,7 @@ jobs: run: | #don't check modded files git update-index --assume-unchanged lib/yt_dlp/extractor/_extractors.py - git update-index --assume-unchanged lib/yt_dlp/extractor/generic.py + git update-index --assume-unchanged lib/yt_dlp/extractor/youtube.py if [[ -z $(git status --porcelain) ]]; then echo "clean=true" >> $GITHUB_ENV @@ -59,7 +60,7 @@ jobs: #don't track modded files git update-index --assume-unchanged lib/yt_dlp/extractor/_extractors.py - git update-index --assume-unchanged lib/yt_dlp/extractor/generic.py + git update-index --assume-unchanged lib/yt_dlp/extractor/youtube.py git add -A git commit -m "yt_dlp: ${{ env.commit_upstream }}" diff --git a/README.md b/README.md index d4d0dfa..8519814 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ _By removing all extractors that are irrelevant to TVer.jp, yt-dlp-tver not only If this approach ultimately proves to be a poor decision, I can still take solace in the fact that I gained valuable knowledge about GitHub Actions along the way. ## Modifications -Besides removing all extractors that aren't necessary for extracting a valid stream manifest URL from TVer.jp, there had to be made some minor changes to [_extractors.py](lib/yt_dlp/extractor/_extractors.py) and (sadly) [generic.py](https://gist.github.com/kuriho/6030dbda5bb07dc8f307d78d2770457e/revisions?diff=unified). +Besides removing all extractors that aren't necessary for extracting a valid stream manifest URL from TVer.jp, there had to be made some minor changes to [_extractors.py](lib/yt_dlp/extractor/_extractors.py) and [youtube.py](lib/yt_dlp/extractor/youtube.py). ## CI pipeline drawing diff --git a/lib/yt_dlp/extractor/generic.py b/lib/yt_dlp/extractor/generic.py index ce1b840..5dff9fe 100644 --- a/lib/yt_dlp/extractor/generic.py +++ b/lib/yt_dlp/extractor/generic.py @@ -6,6 +6,7 @@ from .common import InfoExtractor # isort: split from .commonprotocols import RtmpIE +from .youtube import YoutubeIE from ..compat import compat_etree_fromstring from ..utils import ( KNOWN_EXTENSIONS, @@ -2634,6 +2635,8 @@ def _extract_embeds(self, url, webpage, *, urlh=None, info_dict={}): if isinstance(src_type, str): src_type = src_type.lower() ext = determine_ext(src).lower() + if src_type == 'video/youtube': + return [self.url_result(src, YoutubeIE.ie_key())] if src_type == 'application/dash+xml' or ext == 'mpd': fmts, subs = self._extract_mpd_formats_and_subtitles( src, video_id, mpd_id='dash', fatal=False) @@ -2703,6 +2706,8 @@ def _extract_embeds(self, url, webpage, *, urlh=None, info_dict={}): }, json_ld)] def check_video(vurl): + if YoutubeIE.suitable(vurl): + return True if RtmpIE.suitable(vurl): return True vpath = urllib.parse.urlparse(vurl).path @@ -2814,6 +2819,10 @@ def filter_video(urls): video_url = urllib.parse.urljoin(url, video_url) video_id = urllib.parse.unquote(os.path.basename(video_url)) + # Sometimes, jwplayer extraction will result in a YouTube URL + if YoutubeIE.suitable(video_url): + entries.append(self.url_result(video_url, 'Youtube')) + continue video_id = os.path.splitext(video_id)[0] headers = { @@ -2875,4 +2884,4 @@ def filter_video(urls): # 'url' results don't have a title if e.get('title') is not None: e['title'] = '%s (%d)' % (e['title'], num) - return entries + return entries \ No newline at end of file diff --git a/lib/yt_dlp/extractor/youtube.py b/lib/yt_dlp/extractor/youtube.py new file mode 100644 index 0000000..9cf77ea --- /dev/null +++ b/lib/yt_dlp/extractor/youtube.py @@ -0,0 +1,6 @@ +from .common import InfoExtractor + +class YoutubeIE(InfoExtractor): + @classmethod + def suitable(cls, url): + return False