Skip to content

Commit

Permalink
[media] Process any YouTube-like URL (including Piped/Invidious) befo…
Browse files Browse the repository at this point in the history
…re play.

Media URLs from alternative YouTube backends may include the configured
Piped/Invidious instance instead of youtube.com.

This prevents the yt-dlp matcher from processing them.
  • Loading branch information
Platypush CI/CD Automation committed Jan 28, 2025
1 parent e697c66 commit 0fe399f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions platypush/plugins/media/_resource/parsers/http.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
from typing import Optional

from .. import HttpMediaResource
Expand All @@ -13,6 +14,11 @@ class HttpResourceParser(MediaResourceParser):

def parse(self, resource: str, *_, **__) -> Optional[HttpMediaResource]:
if resource.startswith('http://') or resource.startswith('https://'):
# Process YouTube-like URLs
m = re.match(r'^https?://[^/]+/watch\?v=([^&]+).*', resource)
if m:
resource = f'https://www.youtube.com/watch?v={m.group(1)}'

assert self._media.is_media_file(
resource
), f'Invalid media resource: {resource}'
Expand Down

0 comments on commit 0fe399f

Please sign in to comment.