Closed ycs77 closed 1 month ago
mpv-handler doesn't do this work. The title is obtained by yt-dlp parsing the URL or mpv parsing the video file. I am not sure about your use case. If you play a video from the website supported by yt-dlp but do not get the correct title, please go to yt-dlp to give feedback.
I don't use yt-dlp
.
I have a playlist containing the video's m3u8 URL, the title now only gets from the video path, and each video is shown the title playlist.m3u8
:
https://example.com/aaa/playlist.m3u8
https://example.com/bbb/playlist.m3u8
https://example.com/other/playlist.m3u8
Now open the video basic example mpv command like this:
mpv https://example.com/aaa/playlist.m3u8
mpv https://example.com/bbb/playlist.m3u8
mpv https://example.com/other/playlist.m3u8
And the custom video title of the mpv command like this
mpv https://example.com/aaa/playlist.m3u8 --title="A custom title"
mpv https://example.com/bbb/playlist.m3u8 --title="B custom title"
mpv https://example.com/other/playlist.m3u8 --title="My custom title"
So I want to support the custom title parameter for the mpv-handler.
So, you have a self maintenance userscript to support some special sites?
So, you have a self maintenance userscript to support some special sites?
Yes.
I have implemented this feature, but when testing it I found that --title
does not work. It always shows filename.
And I'm wondering if this feature is necessary. If the m3u8 file is created by yourself, it is better to try adding #EXTINF:
.
I implemented this feature in #64, but this is my first writing the Rust, I have some shortcomings, please adjust them better 😅.
This worked in Windows 11 (my work OS), but I don't know if Linux is work possible.
Done, please try v_title
option. You should encode title by url-safe base64.
Thanks!
And now is have another bug. If the v_title
contains Chinese characters will throw the error InvalidCharacterError: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.
, so I'll use the other method instead the btoa()
function, final I require the package js-base64
into my user script to solve this problem.
// ==UserScript==
// ...
// @require https://cdn.jsdelivr.net/npm/js-base64@3.7.7/base64.min.js
// ==/UserScript==
// this will throw `InvalidCharacterError`
let data = btoa("ä½ å¥½ï¼Œä¸–ç•Œ");
// change to this will be solved
let data = Base64.encode("ä½ å¥½ï¼Œä¸–ç•Œ");
let safe = data.replace(/\//g, "_").replace(/\+/g, "-").replace(/\=/g, "");
I think adding this solution to README will be better, let others know about this situation.
It's just a simple example. You can use the js-base64 library, but it's not the only way.
And js-base64 provides a url-safe encoding method Base64.encodeURI
I see. Thanks for your reply!
Could you support the
title
parameter for mpv-handler from mpv--title
? Because the title sometimes always shows theplaylist.m3u8
from the URL, I want to customize it. And thanks for your package helping me🥰The
--title
option reference: https://github.com/mpv-player/mpv/blob/53f2619dbd740b71bdd4277f096d077ffb8d571b/DOCS/man/options.rst#window