Skip to content
Merged
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
40 changes: 35 additions & 5 deletions catt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ def cli(ctx, device):
metavar="TIME",
help="Start playback at specific timestamp.",
)
@click.option(
"-l",
"--title",
metavar="TITLE",
help="Specify a title for the media file.",
)
@click.option(
"-v",
"--volume",
type=click.IntRange(0, 100),
metavar="LVL",
help="Set volume (0-100).",
)
@click.option(
"-b",
"--block",
Expand All @@ -238,6 +251,8 @@ def cast(
no_playlist: bool,
ytdl_option,
seek_to: str,
title: str,
volume: int,
stream_type: str,
block: bool = False,
):
Expand Down Expand Up @@ -300,20 +315,23 @@ def cast(
click.echo(
'{} "{}" on "{}"...'.format(
"Showing" if media_is_image else "Playing",
stream.video_title,
title or stream.video_title,
cst.cc_name,
)
)
if volume is not None:
cst.volume(volume / 100.0)

if cst.info_type == "url":
cst.play_media_url(
stream.video_url,
title=stream.video_title,
title=title or stream.video_title,
content_type=stream.guessed_content_type,
subtitles=subs.url if subs else None,
thumb=stream.video_thumbnail,
current_time=seek_to,
stream_type=stream.stream_type,
media_info=stream.media_info,
stream_type=getattr(stream, "stream_type", None),
media_info=getattr(stream, "media_info", None),
)
elif cst.info_type == "id":
cst.play_media_id(stream.video_id, current_time=seek_to)
Expand Down Expand Up @@ -564,7 +582,19 @@ def scan(json_output):
devices = get_cast_infos()

if json_output:
echo_json({d.friendly_name: d._asdict() for d in devices})
echo_json(
{
d.friendly_name: {
"host": d.host,
"port": d.port,
"uuid": d.uuid,
"model_name": d.model_name,
"friendly_name": d.friendly_name,
"manufacturer": d.manufacturer,
}
for d in devices
}
)
else:
if not devices:
raise CastError("No devices found")
Expand Down
3 changes: 3 additions & 0 deletions catt/stream_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ def _get_stream_info(self, preinfo):
raise ExtractionError("yt-dlp extractor failed")

def _get_stream_url(self, info):
if info.get("direct"):
return info["url"]

try:
format_selector = self._ydl.build_format_selector(self._best_format)
except ValueError:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_catt.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def test_stream_info_other_video(self):
self.assertTrue(stream.is_remote_file)
self.assertEqual(stream.extractor, "twitch")

def test_stream_info_direct_link(self):
url = "https://homeazan.com/file_example_MP3_700KB.mp3"
stream = StreamInfo(url)
self.assertEqual(stream.video_url, url)
self.assertTrue(stream.is_remote_file)
self.assertTrue(stream._is_direct_link)


if __name__ == "__main__":
import sys
Expand Down
Loading