axcore / tartube

A GUI front-end for youtube-dl, partly based on youtube-dl-gui and written in Python 3 / Gtk 3
GNU Lesser General Public License v2.1
1.92k stars 105 forks source link

Metadata transfer for input.m3u to output.m3u for streaming #615

Open siliconhippy opened 5 months ago

siliconhippy commented 5 months ago

Great work πŸ‘

I was wondering if the Tartube platform can be enhanced for tv channels streaming, without necessarily video downloading, by using a custom input.m3u playlist ( including live and VoD YouTube channels, and other sites) that can then output to output.m3u for feeding into external players like VLC, Kodi and Jellyfin m3u tuner?

Here the problem I see is that metadata like tvg-chno, tvg_name, tvg_logo, tvg_epg etc are not transferred to the output.m3u playlist, as I can surmise ?

Maybe also some options for selecting metadata tags that are available already in input.m3u ?

People can write Linux bash scripts loops to transfer metadata but then looping multiple stream URLs for streamlink or yt_dlp processing can also be included, obviating need for a GUI tool. Not clear how such a script works work with Tartube, without any CLI menu.

But incorporating metadata transfer in Tartube avoids writing CLI or scripts which is the whole GUI idea ! And Tartube is quite comprehensive.

axcore commented 5 months ago

I haven't worked with .m3u playlists, so I don't quite understand what problem you are trying to solve. Under what circumstances would you want to create a custom .m3u playlist, to piped into VLC?

siliconhippy commented 5 months ago

Thanks for responding ☺️

I just thought that with Tartube as #1media downloader, we might as well have integration for IPTV m3u playlists streaming only, no downloads integration.

That are lots of people using Kodi, Jellyfin and Plex and VLC who put together their own IPTV playlists and stream for live channels, without any DVR.

It looks like Tartube can use both streamlink or yt_dlp to allow an input.m3u to be processed into an output.m3u playlist without downloads. But the #EXTM3U metadata tags, tvg-id, -logo, -name, -epg etc from input.m3u are not available in output.m3u, because streamlink or yt_dlp don't retain these tags, just process stream URLs, by definition.

So for streamlink you will need to write a sed regex loop to extract these tags. For yt_dlp, luckily there is an inbuilt --exec command that extracts these tags.

Of course cli typing is onerous and error prone with multiple lists and updates. A Tartube GUI feature add will be great !

Examples:

  1. https://cgomesu.com/blog/Tvhlink/#building-m3u-playlists

( Just start with tvhlink m3u playlists section, for streamlink piping.)

  1. For yt_dlp a Skype Bing Chat prompted loop bash example:

!/bin/bash

Define the input and output playlist files

input_playlist="input.m3u" output_playlist="output.m3u"

add /data/myscripts and /data/myscripts2

or, PATH=/root:$PATH This will allow you #to run the script by just typing script.sh

PATH=/data/myscripts:/data/myscripts2:$PATH

Define the URL of the input playlist

input_url="URL_input_m3u"

Download the input playlist from a remote server using wget

wget -O $input_playlist $input_url

Run yt-dlp with the desired options

yt-dlp -a input.m3u -f "bestvideo[height<=720]+bestaudio/best" --skip-download --hls-use-mpegts --no-progress --playlist-metadata-from-title "%(tvg_id)s %(tvg_name)s %(tvg_logo)s %(group_title)s %(tvg_chno)s %(tvg_epg)s" --no-playlist-metafiles --exec "echo #EXTINF:-1, tvg-id=\"{id}\", tvg-name=\"{title}\", tvg-logo=\"{thumbnail}\", group-title=\"{playlist_title}\", tvg-chno=\"{tvg_chno}\", tvg-epg=\"{tvg_epg}\", {title} >> output.m3u; echo {url} >> output.m3u"

chmod +x yt_dlp.sh

set up cronjob to refresh m3u files !


.

axcore commented 3 months ago

A small update: I don't understand how to implement your request, so I have not tried to do it yet.

siliconhippy commented 3 months ago

Perhaps you can look at this tvlink project (Google translated from Ukrainian) that builds a GUI on top of streamlink with full m3u metadata transfer, etc:

https://forum.alexelec.tv/index.php?topic=324.msg4082&_gl=1*43f22y*_ga*Njc4NDIwNTkxLjE3MDgzMTgyOTY.*_ga_00383BV2N7*MTcwOTc0MjA5MC4zLjAuMTcwOTc0MjA5Ni41NC4wLjA.#msg4082

The first link for x86 goes to the GitHub with source code.