Closed candrapersada closed 2 months ago
To check mpv's wiki
https://github.com/NaiveInvestigator/save-playlist/blob/main/save-playlist.lua
change top two lines adding playlists/
local playlist_savepath = (os.getenv('APPDATA') or os.getenv('HOME')..'/.config')..'/mpv/playlists/'
--local playlist_savepath = mp.get_property('working-directory')
then create a directory called playlists in mpv config directory it'll write a playlist to ./config/mpv/playlists with a filename like 1726631381-size_2-playlist.m3u
in input.conf
Ctrl+Alt+p script-message save-playlist #! [Playlist] > Save .m3u playlist to config dir
and make sure to have the open config dir for easy access
Shift+F6 script-binding uosc/open-config-directory #! [Utilities] > Open Config Directory
I was using the https://github.com/CogentRedTester/mpv-scripts/blob/master/save-playlist.lua and it prompts for you to name the playlist but requires user-input.lua and user-input-module.lua
Ctrl+Alt+p script-message save-playlist ~~/playlists/ #! [Playlist] > Save .m3u playlist to config dir
it works fine though but wanna keep it simple
If you queue up a bunch of URLs and save it it'll only show URLs without the titles. Same thing if you paste a playlist URL it'll initially show the titles in the uosc playlist but upon saving it has only the yt url and not the titles.
This little one-liner will give you titles to the playlist so next time you open it with mpv it'll display the titles in the playlist
ls *.m3u && playlist=$(bash -c 'read -e -p "Input filename of m3u playlist to get youtube titles: " tmp; echo $tmp') && yt-dlp --skip-download --no-warnings -O "#EXTINF:%(playlist_index)s,%(upload_date>%Y%m%d)s %(title)s" -O webpage_url -a "$playlist" > ${playlist%.*}_titles.m3u
Assuming you use the
Ctrl+Alt+p script-message save-playlist #! [Playlist] > Save .m3u playlist to config dir
which save the yt URL in a playlist. It'll open the playlist in mpv but without titles.
Now to either get yt titles or get yt titles in reverse assuming your playlists are in ~/.config/mpv/playlists
change scripts for windows to %homedrive%%homepath%\.config\mpv\playlists (I think that's correct)
# run "/bin/bash" "-c" 'cd ~/Desktop/mpvdata/download/srtfixer; ./m3u_yt_titles.sh' ; show-text "Titles are being added to all yt .m3u playlists"#! [Playlist] > Add titles to all yt .m3u playlists
# run "/bin/bash" "-c" 'cd ~/Desktop/mpvdata/download/srtfixer; ./m3u_yt_titlesreverse.sh' ; show-text "Titles are being added to all yt .m3u playlists"#! [Playlist] > Add titles in reverse to all yt .m3u playlists
now place these two scripts m3u_yt_titles.sh
cd ~/.config/mpv/playlists
[ ! -d titles ] && mkdir titles
for f in *.m3u
do yt-dlp --skip-download --flat-playlist --no-warnings -O "#EXTINF:,%(upload_date>%Y%m%d)s %(title)s %(duration>[%H:%M])s" -O webpage_url -a "$f" > titles/"$f"
done
dt=$( date +%Y_%m_%d_%H_%M_%S)
mkdir "$dt" && mv *.m3u "$dt"
and m3u_yt_titlesreverse.sh
cd ~/.config/mpv/playlists
[ ! -d titles_reversed ] && mkdir titles_reversed
for f in *.m3u ; do cat "$f" | awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' > ${f%.*}.m3u8 ; done
for f in *.m3u8
do yt-dlp --skip-download --flat-playlist --no-warnings -O "#EXTINF:,%(upload_date>%Y%m%d)s %(title)s %(duration>[%H:%M])s %(uploader)s" -O webpage_url -a "$f" > titles_reversed/"${f%.*}".m3u
done
dt=$( date +%Y_%m_%d_%H_%M_%S)
mkdir "$dt" && mv *.m3u *.m3u8 "$dt"
is there any feature or scripts to
save playlist
to m3u/m3u8?