Export all channels of tvheadend inside a m3u playlist file
Added by Alessio Pollero over 8 years ago
Hi,
I'm just wondering if it is possible to export all the available channels inside tvheadend as an m3u playlist file so that I can open the exported file with VLC or any other player that supports the format and watch the TV directly from there, without having to pass through the tvheadend web interface.
The protocol that I want to use to play the files is standard pass though without any transcoding .
Thanks .
Replies (24)
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Mark Clarkstone over 8 years ago
Alessio Pollero wrote:
Hi,
I'm just wondering if it is possible to export all the available channels inside tvheadend as an m3u playlist file so that I can open the exported file with VLC or any other player that supports the format and watch the TV directly from there, without having to pass through the tvheadend web interface.The protocol that I want to use to play the files is standard pass though without any transcoding .
Thanks .
HTH..
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Alessio Pollero over 8 years ago
Is it possible to insert the username and password as arguments to the URL like :
http://ip:9981/playlist&username=user&password=psw
I've tried, but I get : 1 Unknown Code
RE: Export all channels of tvheadend inside a m3u playlist file - Added by spyer spyer over 8 years ago
i need it, too.
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Jonathan Thomson over 8 years ago
From a web browser;
http://USERNAME:PASSWORD@YourTVHeadendIP:9981/playlist/channels.m3u?profile=YOURPROFILENAME
using cURL
curl -u USERNAME:PASSWORD http://YourTVHeadendIP:9981/playlist/channels.m3u?profile=YOURPROFILENAME
using wget
wget --user=USERNAME --password=PASSWORD http://YourTVHeadendIP:9981/playlist/channels.m3u?profile=YOURPROFILENAME
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Rostislav KRICKA almost 8 years ago
Ahoj, dá se nějak upravit čas trvání vygenerovaného playlistu ??? Děkuji
Hey, you can somehow adjust the time duration generated playlist ??? Thank you
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Jaroslav Kysela almost 8 years ago
If you mean the time when the streaming tickets are valid, then the answer is no - there's a hardcoded value - 5 minutes in src/access.c (TICKET_LIFETIME).
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Joe User almost 8 years ago
You could use one of the following scripts to generate a playlist. It is not very secure since it will include the user:password, but if that doesn't bother you...
For all enabled services:
#!/bin/bash # you must have installed jq (apt-get install jq) ############### BEGIN CONFIG ################### tvh_data_path="/home/hts/.hts" profile="profile" admin_pass="admin:password" user_pass="user:password" host="192.168.1.13:9981" ############### END CONFIG ################### wget -O /tmp/services_unsorted.json http://$admin_pass@localhost:9981/api/mpegts/service/grid?limit=100000 #cp /tmp/services_unsorted.json /tmp/services.json jq '.entries |= sort_by(.network, .svcname)' /tmp/services_unsorted.json > /tmp/services.json echo \#EXTM3U entries=$(/usr/bin/jq -c '.total' /tmp/services.json) for (( service=0; service<= $entries; service++ )) do enabled=$(/usr/bin/jq -c '.entries['$service'].enabled' /tmp/services.json) if [ "$enabled" = "true" ] then svcname=$(/usr/bin/jq -c -r '.entries['$service'].svcname' /tmp/services.json) uuid=$(/usr/bin/jq -c -r '.entries['$service'].uuid' /tmp/services.json) network=$(/usr/bin/jq -c -r '.entries['$service'].network' /tmp/services.json) multiplex=$(/usr/bin/jq -c -r '.entries['$service'].multiplex' /tmp/services.json) desc="$network/$multiplex/$svcname" echo \#EXTINF:-1, $desc echo http://$userpass@$host/stream/service/$uuid\?profile=$profile fi done #rm /tmp/services_unsorted.json /tmp/services.json
For all enabled channels:
#!/bin/bash # you must have installed jq (apt-get install jq) ############### BEGIN CONFIG ################### tvh_data_path="/home/hts/.hts" profile="profile" admin_pass="admin:password" user_pass="user:password" host="192.168.1.13:9981" ############### END CONFIG ################### wget -O /tmp/channels_unsorted.json http://$admin_pass@localhost:9981/api/channel/grid?limit=100000 #cp /tmp/channels_unsorted.json /tmp/channels.json #jq '.entries |= sort_by(.name)' /tmp/channels_unsorted.json > /tmp/channels.json jq '.entries |= sort_by(.number)' /tmp/channels_unsorted.json > /tmp/channels.json echo \#EXTM3U entries=$(/usr/bin/jq -c '.total' /tmp/channels.json) for (( service=0; service<= $entries; service++ )) do enabled=$(/usr/bin/jq -c '.entries['$service'].enabled' /tmp/channels.json) if [ "$enabled" = "true" ] then svcname=$(/usr/bin/jq -c -r '.entries['$service'].svcname' /tmp/channels.json) uuid=$(/usr/bin/jq -c -r '.entries['$service'].uuid' /tmp/channels.json) name=$(/usr/bin/jq -c -r '.entries['$service'].name' /tmp/channels.json) number=$(/usr/bin/jq -c -r '.entries['$service'].number' /tmp/channels.json) desc="$number - $name" echo \#EXTINF:-1, $desc echo http://$userpass@$host/stream/channel/$uuid\?profile=$profile fi done #rm /tmp/channels_unsorted.json /tmp/channels.json
Edit the top section with the correct data for you (admin username/password, user username/password, profile, and host address:port)
To create an unsorted list, comment out the jq sort and uncomment the cp command.
If you do not want to specify the profile (and just use the default) you can remove the part "\?profile=$profile" from the end of the line.
To see the output in a more readable format, try:
python -m json.tool /tmp/services.json
From there you can see what fields can be used for sorting and/or in the description.
Also, when you get it working how you want, you should probably uncomment the rm at the bottom
Original script was by B C taken from here: [[https://tvheadend.org/boards/4/topics/18131?r=19432]]
export channels to mediatomb - Added by sanshiro san about 7 years ago
here is my contribution to this thread: the above script is modified to inject all channels into mediatomb
channel.sh (2.47 KB) channel.sh |
RE: Export all channels of tvheadend inside a m3u playlist file - Added by psy psycmos about 7 years ago
Thanks a lot for your contribution! Works perfect
RE: export channels to mediatomb - Added by Eugen Stelea almost 7 years ago
sanshiro san wrote:
here is my contribution to this thread: the above script is modified to inject all channels into mediatomb
How does this work?
Seems i'm missing something, when i run the script i get this:
Error: near line 1: no such table: mt_cds_object
Error: near line 2: no such table: mt_cds_object
and so on for all the channels...
Thanks!
RE: Export all channels of tvheadend inside a m3u playlist file - Added by sanshiro san almost 7 years ago
I don't know to what extend you're familiar with scripting and databse/sql
this scripts works when mediatomb is installed with a sqlite database
- the database file contains a table named "mt_cds_object" which inventories all items exposed by mediatomb
- your error probably happens when it execute the command:
cat channels.sql | sqlite3 mediatomb.db
so I'd recommend the following:
- ensure your mediatomb uses sqllite (although I am not aware about other setup it may run with mysql ?)
- if this is the case, browse around google to dig into your mediatomb.db sqlite database and list all table it contains (probably something like .schema)
alternatively, you can provide a log or more info on the context and I can try to help
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Eugen Stelea almost 7 years ago
Thank you!
I am not familiar with linux scripting and database / sql, but i'm doing my best.
I already have mediatomb up and running on my tvheadend machine (Ubuntu 14) with just a couple of TV channels configured by hand, so your script would fill in the gap.
You're correct, those errors popped up when running that last command that should inject the channels into the mediatomb database.
It's the default mediatomb packaged installed with apt-get, so i'm pretty sure it's using sqllite.
I will give it another shot tomorrow, hope i manage to run it successfully.
Long live virtual machines!
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Cleiton Oppenheimer over 6 years ago
I was not able to download the m3u file with the links using the above mentioned solutions. I have not tried with linux...
It seems that it is no longer working since when i try to use
http://USERNAME:PASSWORD@YourTVHeadendIP:9981/playlist/channels.m3u?profile=YOURPROFILENAME
it requests the login and pw again.
Is there any other solution/new solution?
Thanks
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Anonymous over 6 years ago
Try to Enable Both standard and digest authentication in tvheadend -> Configuration -> Base -> HTTP Server Settings -> Authentication Type if you use tvheadend 4.3
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Jaker MX over 6 years ago
If you are trying all the suggestions above,and you are not getting the same results as playing the Network/Mux url on VLC, first you need to uncheck HTTP Digest Authentication from General config, then yo have to create a new stream profile type Pass-Through, and uncheck the four rewrite options, after that, you need to add a new user and pass and finally, create an access control for that user, selecting just the created profile, define as none the Preferred service video type option and check the Switch to another service option...
After that, download your playlist using http://user:pass@server:9981/playlist(this will create two request to server, once junidentified and another one with basic auth, so for half a minute you will see two subscriptions) and thats it, enjoy it.... if your media includes, mp3, mp4, avi , etc... you may use another type of stream profile...or, get the channel list streams directly from /api/channels/grid and use uuid on /stream/channel/uuid, and get the original url for the rest of channels from the /api/mpegts/mux/grid...
Anything yo get from the htv server at least will be proxying the packets, unless yo use the mux URL from api o the media fall on no profile and switch to something I call, all-pass.profile.
I am running on the same thing becausse I am using TVH on RaspPi, and I am using TVH as Media Hub, so It controls my live subscriptions, and provedes acurate EPG, and for the other media, TVH acts as URI repository....
RE: Export all channels of tvheadend inside a m3u playlist file - Added by saen acro over 6 years ago
By default all playlist are exported with pass profile,
same for users.
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Jaker MX over 6 years ago
pass profile handles some stuff, it is not a transparent pass-through at all,
i.e. this entry
#EXTINF:-1 tvg-id="" tvg-name="Avengers: Infinity War" tvg-logo="http://i.ytimg.com/vi/i47RBXqE2kU/0.jpg" group-title="ESTRENOS-CAM-TS",Avengers: Infinity War
http://disfruta.club:8000/movie/cesarsalinas/cesarsalinas/13605.mp4
if you open a networ stream on VLC, WM, etc, it plays... but, if you add the m3u in IPTV automatic, and then try to play it as MUX, Service, Channel or part of Bouquet, nothing happens, and the service.log just says, no input detected, I have tried all the default stream profiles, and some custom ones, thats why I was looking for some flag on api that create the playlist with the epg data and stream stufff for live tv, and mux info for non-compatible stuff like the on I sent.
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Jaroslav Kysela over 6 years ago
#EXTINF:-1 tvg-id="" tvg-name="Avengers: Infinity War" tvg-logo="http://i.ytimg.com/vi/i47RBXqE2kU/0.jpg" group-title="ESTRENOS-CAM-TS",Avengers: Infinity War
http://disfruta.club:8000/movie/cesarsalinas/cesarsalinas/13605.mp4
You're confused. TVH accepts only MPEG-TS stream as the source and you're trying to feed the mp4 data. So you need to use pipe:// and let another tool to convert the source to MPEG-TS or the recent development tvh versions have 'use libav' switch in the mux / network settings. This switch will force tvh to use linked ffmpeg library for the container conversion for the given mux.
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Jaker MX over 6 years ago
I know that, but usually providers push m3u playlist in ts format, including a lot of streams on it in diferent formats mp4, mp3, etc.. so TVH on IPTV Auto, creates mux, service, channels and channels tags related to them... and playing them is a really mess, or editing them in order to make them compatible is a real hard work...and taking care of available resources, talking about RasPi, it is better to be a provisoner instead a packet proxy and nothing to say about being transcoder...performance is limited, but we can maximize resources using alternatie paths (i.e. Cisco Call Manager and its SIP Framework formerly VOVIDA Task Force, who created SIP fighting verus h323, SCCP ,etc... the idea is deliver the service needed, no matter the way, in this context, they implemented the concept of sip full proxy when resources are available and sip proxyless when not... I am just trying to find a way to get their need met.)
Cheers
:=)
RE: Export all channels of tvheadend inside a m3u playlist file - Added by saen acro over 6 years ago
Live streams, VOD streams, big mistakes that are same thing.
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Jaker MX over 6 years ago
If they are the same, why are they not working?
Both are streams of video, both they are not handled in the same way...so whatever, I am just trying to find a way to stream them easily.
I am new on RasPi, LibreElec, KODI and TVH, I have been disabled since November because an accident, but I started working on KODI about 18 days, on TVH 1 week or less...so I respect what you all think, but I am here , Ithink as everybody ,looking for solutions...
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Daniel Lewandowski over 1 year ago
Is it going to fetch the m3u list from tvheadend so it doesn't ask for login and password? Every time I download and run the list in VLC it asks for login and password.
RE: Export all channels of tvheadend inside a m3u playlist file - Added by saen acro over 1 year ago
Daniel Lewandowski wrote:
Is it going to fetch the m3u list from tvheadend so it doesn't ask for login and password? Every time I download and run the list in VLC it asks for login and password.
You use non persistent url
http://user:[email protected]:9981/playlist/auth/channels
in user password need to enable persistent authentication
RE: Export all channels of tvheadend inside a m3u playlist file - Added by Daniel Lewandowski over 1 year ago
I don't know where to attach the options yet. after completing the data, it displays a message on the 403 Forbidden page
when doing http://ip:9981/playlist it is normally downloaded but with authorization requirement