Theradioguy 6 Posted December 22, 2023 Share Posted December 22, 2023 Hello, I have a large number of channels in TVHeaded, each categorized by one or more tags. I am wondering if there is a way to translate the TVHeadend tags to Emby tags, so that I don't need to duplicate all the work I have done on the TVHeadend side. For context, I am using the Emby tags to gate access to channels for some users of my Emby server. Link to comment Share on other sites More sharing options...
Woken 12 Posted December 24, 2023 Share Posted December 24, 2023 On 12/22/2023 at 6:59 PM, Theradioguy said: Hello, I have a large number of channels in TVHeaded, each categorized by one or more tags. I am wondering if there is a way to translate the TVHeadend tags to Emby tags, so that I don't need to duplicate all the work I have done on the TVHeadend side. For context, I am using the Emby tags to gate access to channels for some users of my Emby server. Emby should see the tags you created in tvheadend and pass em through on the emby side, in the past it had done this for me. Unless you edited your m3u file after you used it as http://192.168.1.1:9981/playlist/channels ? Link to comment Share on other sites More sharing options...
Theradioguy 6 Posted December 24, 2023 Author Share Posted December 24, 2023 Thanks for the reply, I don't see any tags in the Emby side, however, I'm not using the m3u8 method of importing channels, I'm using the TVHeadend plugin. Is using the m3u option the better way of adding channels into Emby? Does it still transfer guide data from TVheadend? Link to comment Share on other sites More sharing options...
Solution Q-Droid 665 Posted December 24, 2023 Solution Share Posted December 24, 2023 I don't know what the plugin can do with tags. I only used the plugin once and found it to be so limited that I immediately switched to m3u. You can create a separate m3u tuner in Emby for each tag (group) you have in TVH. Or for any channel grouping you might have. You can also use the API to pull the xmltv guide data from TVH for the corresponding tags and associate them with the matching tuners. Link to comment Share on other sites More sharing options...
Theradioguy 6 Posted December 25, 2023 Author Share Posted December 25, 2023 6 hours ago, Q-Droid said: I don't know what the plugin can do with tags. I only used the plugin once and found it to be so limited that I immediately switched to m3u. You can create a separate m3u tuner in Emby for each tag (group) you have in TVH. Or for any channel grouping you might have. You can also use the API to pull the xmltv guide data from TVH for the corresponding tags and associate them with the matching tuners. Thanks for the suggestion! I'll look into pulling the EPG data out of TVHeadend and into emby, have a bit of experience working with APIs, so if it's exposed then I don't think it will be too difficult. Link to comment Share on other sites More sharing options...
Luke 37191 Posted December 26, 2023 Share Posted December 26, 2023 Support for this could be added to the Emby TVHeadEnd plugin, somewhere in here most likely: https://github.com/MediaBrowser/Tvheadend/blob/master/TVHeadEnd/DataHelper/ChannelDataHelper.cs#L65 Link to comment Share on other sites More sharing options...
Theradioguy 6 Posted January 3 Author Share Posted January 3 (edited) Just as an update, using the m3u output along with xmltv worked great. used the following URL to add the TVHeadend channels via m3u: http://x.x.x.x:9981/playlist/channels?profile=pass And then I added an XMLTV source and also pointed it to the TVHeadend server: http://x.x.x.x:9981/xmltv/channels The channels automatically mapped to the guide data without needing to do anything else. I am still having an issue with tags, in the Emby GUI none of the channels have tags associated with them. When I look at the m3u from TVH in a text editor, I also don't see any tags, is there possibly a different URL I should be using? Edited January 3 by Theradioguy Link to comment Share on other sites More sharing options...
Theradioguy 6 Posted January 3 Author Share Posted January 3 Update, looks like it may not be supported by TVHeadend at this time: https://tvheadend.org/issues/4459 - unfortunate, I'll see if I can write some middlewear to ad the tags manually before Emby sees the m3u 1 Link to comment Share on other sites More sharing options...
Luke 37191 Posted January 3 Share Posted January 3 21 minutes ago, Theradioguy said: Just as an update, using the m3u output along with xmltv worked great. used the following URL to add the TVHeadend channels via m3u: http://x.x.x.x:9981/playlist/channels?profile=pass And then I added an XMLTV source and also pointed it to the TVHeadend server: http://x.x.x.x:9981/xmltv/channels The channels automatically mapped to the guide data without needing to do anything else. I am still having an issue with tags, in the Emby GUI none of the channels have tags associated with them. When I look at the m3u from TVH in a text editor, I also don't see any tags, is there possibly a different URL I should be using? Maybe the tvh url needs a query string param to include the tags in the m3u? Just an idea. Link to comment Share on other sites More sharing options...
Theradioguy 6 Posted January 3 Author Share Posted January 3 writing a php application to grab the m3u from TVH, parse it, add the tags and then spit it back out seems to have done the trick. Tags are now added to Emby. Guessing if TVH ever adds support for the group-title attribute it will work nativly. Thanks for all the support guys. 1 Link to comment Share on other sites More sharing options...
CharlieMurphy 73 Posted January 29 Share Posted January 29 On 1/3/2024 at 12:37 AM, Theradioguy said: writing a php application to grab the m3u from TVH, parse it, add the tags and then spit it back out seems to have done the trick. Tags are now added to Emby. Guessing if TVH ever adds support for the group-title attribute it will work nativly. Thanks for all the support guys. Would you mind sharing this? On 1/2/2024 at 11:18 PM, Luke said: Maybe the tvh url needs a query string param to include the tags in the m3u? Just an idea. There doesn't seem to be an option in TVHeadend to include the tags in m3u. Kodi gets the tags with HTSP though, so the TVHeadend plugin would be able to handle this if the code were there. I found this feature addition giving the option to sort the tags manually: https://tvheadend.org/issues/2560 I would totally do the work on the TVHeadend plugin for Emby but the code is Greek to me. 1 Link to comment Share on other sites More sharing options...
Theradioguy 6 Posted January 29 Author Share Posted January 29 3 hours ago, CharlieMurphy said: Would you mind sharing this? There doesn't seem to be an option in TVHeadend to include the tags in m3u. Kodi gets the tags with HTSP though, so the TVHeadend plugin would be able to handle this if the code were there. I found this feature addition giving the option to sort the tags manually: https://tvheadend.org/issues/2560 I would totally do the work on the TVHeadend plugin for Emby but the code is Greek to me. Sure, the code below is what I am using. I'm just running it on an apache webserver with mod-php. Note that this works specifically for my use case, has limited error checking and is not 'production ready' in any way. <?php //get channels by tag $tags=file_get_contents("https://127.0.0.1:9981/playlist/tags?profile=pass"); $lines = explode("\n", $tags); $ouputM3u=""; foreach ($lines as $line) { // Check if it's a channel line (starts with '#EXTINF') if (strpos($line, '#EXTINF') === 0) { $name = str_replace(',','',substr($line, strpos($line, ',') )); } else { if(strlen($line)>1) { $channelTag=file_get_contents($line); } $channelTags=explode("\n",$channelTag); foreach ($channelTags as $channel) { // Check if it's a channel line (starts with '#EXTINF') if (strpos($channel, '#EXTINF') === 0) { $currTags = substr($channel, 0, strpos($channel, ',') + 1); $channelInfo = substr($channel, strpos($channel, ',') + 1); // Add the group-title tag before the channel name $channel = str_replace(',','',$currTags) . ' group-title="'.$name.'",' . $channelInfo; } $outputM3u .= trim(str_replace("#EXTM3U","",$channel)). "\n"; } } } $outputM3u = preg_replace('/^[ \t]*[\r\n]+/m', '', $outputM3u); echo "#EXTM3U\n".$outputM3u; 2 Link to comment Share on other sites More sharing options...
CharlieMurphy 73 Posted January 30 Share Posted January 30 Thank you so much! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now