Skip to content

Conversation

@medape
Copy link
Contributor

@medape medape commented Nov 1, 2025

Each commit includes a changelog.

I've been working on this code for days on my computer. None of the commits should be broken (the script should work normally no matter which commit do you pick) but I had to edit my commits several times. In particular, my original debugging functions were a nightmare to set up, and replacing them force me to amend all the following commits.

My original intention was to unblock YouTube videos again, but so far, I haven't had any luck.

Newish videos on YouTube (from the last two years?) currently can't be downloaded in a merged format. The only options are:

  • using an M3U8 manifest to download video and audio segments
  • casting a video-only stream
  • or casting an audio-only stream.

The first option works out of the box for the Tears of Steel test video at lolitemaultes/m3u8-urls and for streams from RTVE (Spanish public TV), but when CATT selects a YouTube M3U8 manifest, it just shows the Cast icon over black background.

I couldn't find any way to root my ChromeCast, or figure out debugging. I tried casting video only then adding audio tracks, but not only does the ChromeCast not add them, it stops responding to CATT commands other than catt stop.

Subtitling code should probably go to subs_info.py, but right now moving more code around will take me several days and result in no extra functionality.

Any help is welcome.

EDIT:

  • The mandatory checks on my computer didn't check for api.py... but I just made a tiny change in order not to break the API. (If input device_desc to StreamInfo() was optional, the dict settings replacing it must be optional too).
  • Edited the message for one of the first commits because in order to say Click instead of @click (I'm sorry if I pinged them for no reason).

This change was originally intended to support a verbosity parameter.
However, the method to do this was too complicated, and required us to redefine
too many functions. Instead, it will be used to pass other configuration like
ChromeCast alias or styling information.
CATT is currently keeping track of the `verbosity` variable, which defaults to 0
unless CATT is run with flag `-v`. This flag can stack (up to `-vvvv`).

Severl functions were defined to print debugging messages, but only if
`verbosity` is enough for each specific message:
- echo_warning()
- echo_info()
- echo_verbose()
- echo_debug()
- echo_trace()

Also ran `pre-commit autoupdate`
If a user tries to cast from their local computer an HLS or DASH manifest,
and the stream type is not set to LIVE or BUFFERED, CATT will detect it,
issue a warning, and set it to BUFFERED.
CATT will now also send the correct MIME type when such a file is cast.

Support for Smooth Streaming is unchanged for lack of working example files
for testing.

Additionally, CATT silently ignored any format selector provided to yt-dlp.
Currently, if a format selector is provided, CATT will accept this but
warn the user that no compatibility checks will be made. (CATT will not
check if the format is invalid, or simply incompatible with the current
ChromeCast). If no format selector is provided, CATT will silently choose
the best format as usual.

Also StreamInfo.guessed_content_type is now a regular variable and not a
property calculated on the fly (because it depends on ephemeral information
for remote files) and the HTTP server also responds now to HEAD requests, in
order to avoid confusing errors when casting DASH manifests locally.
The same command used to switch subtitles can be used to switch
between audio tracks, provided that a stream with more than one
is cast.

This command now also outputs type of tracks, language of tracks,
and a tick besides the tracks currently selected.
The code to load new tracks (e.g. for subtitles) is now in its on function,
for easier reuse.

Added more filters to BEST_MAX_2K, as 1st-gen ChromeCasts are not compatible
with newer formats.
This tiny change accepts videos where the parameter is unknown in every filter.
This is needed for videos that do not have metadata, or M3U8 manifests that
link directly to TS files (and also have no metadata)
BUFFERED is always the stream type by default.

The flag to override this is obviously --stream-type live,
not --stream-type BUFFERED
@skorokithakis
Copy link
Owner

Sorry, what does this PR do? "Various changes" isn't very descriptive, and each logically distinct change should really be in its own PR, so it can be merged independently. Thanks for your contribution!

@medape
Copy link
Contributor Author

medape commented Nov 11, 2025

I agree. Though, in this case, pretty much every commit here does its own thing.

Basically, this PR does four things:

  • adds debugging functions, to help me and hopefully other people. Basically users can run catt, catt -v, catt -vv and catt -vvv. With each v, more info is output to the screen.
  • add support to cast .m3u8 files from the computer (very limited for the moment; the current code only allows you to share one file, so these .m3u8 files can only point to online video and audio segments. Also a lot of formats fail, and Google's files fail for some reason)
  • blacklist more videos from the older ChromeCasts (as seen in the commit message for 9f42f0f) AND allow videos with unknown specs (useful when casting .m3u8 files with only one stream and no metadata)
  • small quality-of-life features like fixing Scan in json format doesnt work #486 and improving the output of catt subs -l

I can split it however you want me to, but all commits use the debugging functions I added, so I'd like you to review those first and tell me if you want them or not. If you want them, I'll split that into its own commit and wait for you to merge it; if no, I'll rewrite the other commits to not make use of them.

@skorokithakis
Copy link
Owner

The verbosity levels seem like a great feature, though I feel like you're reinventing logging. Wouldn't the verbosity level just set the logging level DEBUG/INFO/WARNING/ERROR and use Python's built-in logging module? It does basically the exact same you're doing as well.

@medape
Copy link
Contributor Author

medape commented Nov 13, 2025

It is pretty much the same, I just thought logging had a lot of features we could do without, and required some setup to adapt to this program. Like, just using logging is nicer and more extensible, but this felt just as simple, or simpler in practical terms.

You're the boss, though. If you're okay with adding a new dependency for CATT, I can do a couple tests with the logging module and rewrite this.

@skorokithakis
Copy link
Owner

Since logging is in the stdlib, I'd prefer to not reinvent the wheel and use the existing module for this. The added advantage is that every contributor will be familiar with it already, so there's less cognitive load with it too.

@medape
Copy link
Contributor Author

medape commented Nov 14, 2025

Roger that. I may take a bit, but I'll close this PR and open a new one only to add logging. Then I'll create a separate one for video selection and QOL, then a new one for M3U8.

@medape medape closed this Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants