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

substituted youtube-dl with yt-dlp and corrected a bug of youtube streaming #471

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions mkchromecast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def __init__(self, args = None):
self.codec = args.codec

# TODO(xsdg): Add support for yt-dlp
command_choices = ["ffmpeg", "youtube-dl"]
command_choices = ["ffmpeg", "yt-dlp"]
self.command: Optional[str]
if not args.command:
self.command = None
Expand Down Expand Up @@ -230,13 +230,13 @@ def __init__(self, args = None):
else:
if not check_url(args.youtube):
youtube_error = """
You need to provide a URL that is supported by youtube-dl.
You need to provide a URL that is supported by yt-dlp.
"""

# TODO(xsdg): Switch to yt-dlp.
message = """
For a list of supported sources please visit:
https://rg3.github.io/youtube-dl/supportedsites.html
https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md?plain=1

Note that the URLs have to start with https.
"""
Expand Down
6 changes: 3 additions & 3 deletions mkchromecast/_arg_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,12 @@ def raise_arg_type_error():
type=str,
default=None,
help="""
Stream from sources supported by youtube-dl. This option needs
the youtube-dl package, and it also gives you access to all its
Stream from sources supported by yt-dlp. This option needs
the yt-dlp package, and it also gives you access to all its
supported websites such as Dailymotion, LiveLeak, and Vimeo.

For a comprehensive list, check:
http://rg3.github.io/youtube-dl/supportedsites.html.
http://rg3.github.io/yt-dlp/supportedsites.html.

Example:
python mkchromecast.py -y https://www.youtube.com/watch?v=NVvAJhZVBTc
Expand Down
21 changes: 11 additions & 10 deletions mkchromecast/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
frame_size = 32 * _mkcc.chunk_size
buffer_size = 2 * _mkcc.chunk_size**2

encode_settings = pipeline_builder.EncodeSettings(
codec=_mkcc.codec,
adevice=_mkcc.adevice,
bitrate=_mkcc.bitrate,
frame_size=frame_size,
samplerate=str(_mkcc.samplerate),
segment_time=_mkcc.segment_time
)

debug = _mkcc.debug

if debug is True:
Expand All @@ -61,19 +70,11 @@
query = urllib.parse.parse_qs(url_data.query)
video = query["v"][0]
print(colors.options("Playing video:") + " " + video)
command = ["youtube-dl", "-o", "-", _mkcc.youtube_url]
command = ["yt-dlp", "-o", "-", _mkcc.youtube_url]
media_type = "audio/mp4"
else:
backend.name = _mkcc.backend
backend.path = backend.name
encode_settings = pipeline_builder.EncodeSettings(
codec=_mkcc.codec,
adevice=_mkcc.adevice,
bitrate=_mkcc.bitrate,
frame_size=frame_size,
samplerate=str(_mkcc.samplerate),
segment_time=_mkcc.segment_time
)
backend.path = backend.name

# TODO(xsdg): Why is this only run in tray mode???
if _mkcc.operation == OpMode.TRAY and backend.name in {"ffmpeg", "parec"}:
Expand Down
2 changes: 1 addition & 1 deletion mkchromecast/pipeline_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def __init__(self, video_settings: VideoSettings):
@property
def command(self) -> SubprocessCommand:
if self._settings.operation == OpMode.YOUTUBE:
return ["youtube-dl", "-o", "-", self._settings.youtube_url]
return ["yt-dlp", "-o", "-", self._settings.youtube_url]

if self._settings.operation == OpMode.SCREENCAST:
return self._screencast_command()
Expand Down