Project

General

Profile

Feature #3002

Playlist: Add enigma2 playlist generator

Added by Jaroslav Kysela over 9 years ago. Updated over 9 years ago.

Status:
Fixed
Priority:
Normal
Category:
-
Target version:
Start date:
2015-07-07
Due date:
% Done:

100%

Estimated time:

History

#1

Updated by Jaroslav Kysela over 9 years ago

  • Target version set to 4.2
#2

Updated by Jaroslav Kysela over 9 years ago

  • Status changed from Accepted to Fixed
  • % Done changed from 0 to 100

Applied in changeset commit:tvheadend|f6a1da12c40aef1c7c1c206fb2c8efd5e735dab1.

#3

Updated by Alfio Saitta over 9 years ago

My personal implementation:

--- /home/alfio/Projects/tvheadend/src/webui/webui.c
+++ /home/alfio/Projects/IPTVKit/src/webui/webui.c
@@ -588,6 +588,114 @@
 }

+/**
+ * Output a Enigma 2.x playlist with all channels
+ */
+char *replacestr(const char *s, char ch, const char *repl);
+char *replacestr(const char *s, char ch, const char *repl) {
+    int count = 0;
+    const char *t;
+    for(t=s; *t; t++)
+        count += (*t == ch);
+
+    size_t rlen = strlen(repl);
+    char *res = malloc(strlen(s) + (rlen-1)*count + 1);
+    char *ptr = res;
+    for(t=s; *t; t++) {
+        if(*t == ch) {
+            memcpy(ptr, repl, rlen);
+            ptr += rlen;
+        } else {
+            *ptr++ = *t;
+        }
+    }
+    *ptr = 0;
+    return res;
+}
+
+static int
+http_channel_list_enigma2x(http_connection_t *hc)
+{
+    htsbuf_queue_t *hq;
+    idnode_list_mapping_t *ilm;
+    char buf[255];
+    channel_t *ch;
+    channel_t **chlist;
+    channel_tag_t *ct;
+    int idx = 0, count = 0;
+    char *profile, *hostpath;
+
+    if(hc->hc_access == NULL || access_verify2(hc->hc_access, ACCESS_STREAMING))
+        return HTTP_STATUS_UNAUTHORIZED;
+    
+    hq = &hc->hc_reply;
+    
+    profile = profile_validate_name(http_arg_get(&hc->hc_req_args, "profile"));
+    hostpath = http_get_hostpath(hc);
+
+    char *s = replacestr(http_get_hostpath(hc), ':', "%3A");
+    
+    CHANNEL_FOREACH(ch)
+    if (ch->ch_enabled)
+        count++;
+    
+    chlist = malloc(count * sizeof(channel_t *));
+    
+    CHANNEL_FOREACH(ch)
+    if (ch->ch_enabled)
+        chlist[idx++] = ch;
+    
+    assert(idx == count);
+    
+    qsort(chlist, count, sizeof(channel_t *), http_channel_list_playlist_cmp);
+    
+    htsbuf_qprintf(hq, "#NAME IPTV-ENIGMA\n");
+    
+//------------------------------------------
+    TAILQ_FOREACH(ct, &channel_tags, ct_link) {
+        if(!ct->ct_enabled || ct->ct_internal)
+            continue;
+
+        htsbuf_qprintf(hq, "#SERVICE 1:0:1:0:0:0:0:0:0:0:%s\n", s);
+        htsbuf_qprintf(hq, "#DESCRIPTION ---------- %s ----------\n", ct->ct_name);
+
+        LIST_FOREACH(ilm, &ct->ct_ctms, ilm_in1_link) {
+            ch = (channel_t *)ilm->ilm_in2;
+            if (http_access_verify_channel(hc, ACCESS_STREAMING, ch, 0))
+                continue;
+
+            snprintf(buf, sizeof(buf), "/stream/channelid/%d", channel_get_id(ch));
+
+            htsbuf_qprintf(hq, "#SERVICE 1:0:1:0:0:0:0:0:0:0:%s%s?ticket=%s", s, buf, access_ticket_create(buf, hc->hc_access));
+            htsbuf_qprintf(hq, "&profile=%s\n", profile);
+
+            htsbuf_qprintf(hq, "#DESCRIPTION %s\n", channel_get_name(ch));
+        }
+    }
+
+    htsbuf_qprintf(hq, "#SERVICE 1:0:1:0:0:0:0:0:0:0:%s\n", s);
+    htsbuf_qprintf(hq, "%s", "#DESCRIPTION ---------- OnDemand ----------\n");
+//------------------------------------------
+
+    free(chlist);
+    
+    http_output_content(hc, "audio/x-mpegurl");
+    
+    free(hostpath);
+    free(profile);
+  
+    return 0;
+}
+
+/**
+ * Output a Enigma 1.6 playlist with all channels
+ */
+static int
+http_channel_list_enigma16(http_connection_t *hc)
+{
+      return 0;
+}
+

 /**
  * Output a playlist of all recordings.
@@ -746,6 +854,10 @@
     r = http_channel_list_playlist(hc);
   else if(!strcmp(components[0], "recordings"))
     r = http_dvr_list_playlist(hc);
+  else if(!strcmp(components[0], "enigma2x"))
+    r = http_channel_list_enigma2x(hc);
+  else if(!strcmp(components[0], "enigma16"))
+    r = http_channel_list_enigma16(hc);
   else {
     r = HTTP_STATUS_BAD_REQUEST;
   }

#4

Updated by Alfio Saitta over 9 years ago

CleanUp and more TVH friendly:

--- /home/alfio/Projects/tvheadend/src/webui/webui.c
+++ /home/alfio/Projects/IPTVKit/src/webui/webui.c
@@ -707,7 +707,69 @@
   return 0;
 }

-
+static int
+http_channel_list_enigma2x(http_connection_t *hc)
+{
+    htsbuf_queue_t *hq;
+    idnode_list_mapping_t *ilm;
+    char buf[255];
+    channel_t *ch;
+    channel_tag_t *ct;
+    char *profile, *hostpath;
+
+    if(hc->hc_access == NULL || access_verify2(hc->hc_access, ACCESS_STREAMING))
+        return HTTP_STATUS_UNAUTHORIZED;
+    
+    hq = &hc->hc_reply;
+    
+    profile = profile_validate_name(http_arg_get(&hc->hc_req_args, "profile"));
+    hostpath = http_get_hostpath(hc);
+
+    htsbuf_qprintf(hq, "#NAME IPTV-ENIGMA\n");
+    
+    //------------------------------------------
+    // Channels list grouped by tags
+    //------------------------------------------
+
+    TAILQ_FOREACH(ct, &channel_tags, ct_link) {
+        if(!ct->ct_enabled || ct->ct_internal)
+            continue;
+
+        htsbuf_qprintf(hq, "#SERVICE 1:0:1:0:0:0:0:0:0:0:%s\n", hostpath);
+        htsbuf_qprintf(hq, "#DESCRIPTION ---------- %s ----------\n", ct->ct_name);
+
+        LIST_FOREACH(ilm, &ct->ct_ctms, ilm_in1_link) {
+            ch = (channel_t *)ilm->ilm_in2;
+            if (http_access_verify_channel(hc, ACCESS_STREAMING, ch, 0))
+                continue;
+
+            snprintf(buf, sizeof(buf), "/stream/channelid/%d", channel_get_id(ch));
+
+            htsbuf_qprintf(hq, "#SERVICE 1:0:0:0:0:0:0:0:0:0:");
+            htsbuf_append_and_escape_url(hq, hostpath);
+            htsbuf_append_and_escape_url(hq, buf);
+            htsbuf_qprintf(hq, "?ticket=%s", access_ticket_create(buf, hc->hc_access));
+            htsbuf_qprintf(hq, "&profile=%s\n", profile);
+            htsbuf_qprintf(hq, "#DESCRIPTION %s\n", channel_get_name(ch));
+        }
+    }
+
+    //------------------------------------------
+    // DVR Files list
+    //------------------------------------------
+
+        //htsbuf_qprintf(hq, "#SERVICE 1:0:1:0:0:0:0:0:0:0:%s\n", s);
+        //htsbuf_qprintf(hq, "%s", "#DESCRIPTION ---------- OnDemand ----------\n");
+
+    //------------------------------------------
+
+    http_output_content(hc, MIME_E2);
+    
+    free(hostpath);
+    free(profile);
+  
+    return 0;
+}

 /**
  * Output a playlist of all recordings.
@@ -894,6 +956,8 @@
       r = http_channel_list_playlist(hc, pltype);
     else if(!strcmp(cmd, "recordings"))
       r = http_dvr_list_playlist(hc, pltype);
+    else if(!strcmp(cmd, "enigma2x"))
+      r = http_channel_list_enigma2x(hc);
     else {
       r = HTTP_STATUS_BAD_REQUEST;
     }

OUTPUT:

#NAME IPTV-ENIGMA
#SERVICE 1:0:1:0:0:0:0:0:0:0:http://localhost:9981
#DESCRIPTION ---------- DOCUMENTARI ----------
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1760280610?ticket=7863D246FF04F1751843B6D817D1C5EF1BF58C7E&profile=pass
#DESCRIPTION Animal Planet
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F725008504?ticket=7FE36F71786EBB23FAA7216A58BDAFD384F39A10&profile=pass
#DESCRIPTION Baby TV
#SERVICE 1:0:1:0:0:0:0:0:0:0:http://localhost:9981
#DESCRIPTION ---------- INTRATTENIMENTO ----------
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F910331880?ticket=6D82EDD638D0D9162F2ABB5CB61C6BB719428619&profile=pass
#DESCRIPTION DMAX+1
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F29785727?ticket=72C1B56B0139133C472B813C6B2315372CD43344&profile=pass
#DESCRIPTION AXN
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1277217913?ticket=FCC53B080451AA7C8F342BC30C773D4FF2645B4D&profile=pass
#DESCRIPTION DMAX
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F774029743?ticket=7EFBC8B31B629E56325D708BFF049D20A0F709FE&profile=pass
#DESCRIPTION AXN +1
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1599843172?ticket=5063AB854372A5B6782B83FAE623F4E0C35DF9DA&profile=pass
#DESCRIPTION CANALE 5
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1016566114?ticket=5AE8264F704AF62FAE57F0CFB21EFE0F4B33BFA4&profile=pass
#DESCRIPTION AXN Sci-Fi
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F411370549?ticket=404E0EA95045FFB623CD23513A7C91363FFF6A8C&profile=pass
#DESCRIPTION Canale 5
#SERVICE 1:0:1:0:0:0:0:0:0:0:http://localhost:9981
#DESCRIPTION ---------- CALCIO ----------
#SERVICE 1:0:1:0:0:0:0:0:0:0:http://localhost:9981
#DESCRIPTION ---------- BAMBINI ----------
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F2009460036?ticket=5C4ABC5AF2D71F715211902BDEB01670A4567912&profile=pass
#DESCRIPTION Boing
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F138223045?ticket=DC6A150B0B38ED9647521814038A5A41F3030B22&profile=pass
#DESCRIPTION DeAJunior
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1198610822?ticket=2A2EA26127B79A27F71F75B581EB6367D822A147&profile=pass
#DESCRIPTION Cartoon +1
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1916794930?ticket=E168C45F4130A7167345E74975C7482A107EA016&profile=pass
#DESCRIPTION Boomerang +1
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F2103713833?ticket=BB77936F844A20B8D5E207393165033528AD8A16&profile=pass
#DESCRIPTION Cartoon Network
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F547270568?ticket=CC1F6558AD5150E82A35EE5F4CAF0D6E8E79EC39&profile=pass
#DESCRIPTION Boomerang
#SERVICE 1:0:1:0:0:0:0:0:0:0:http://localhost:9981
#DESCRIPTION ---------- SPORT ----------
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F923837563?ticket=6E9B0D7E7D81BD8A1A282FC4C6D8D6098B582245&profile=pass
#DESCRIPTION CACCIA e Pesca
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1695728815?ticket=7259B93DD8C6F4DA53D29FA4B00491435C7B80CF&profile=pass
#DESCRIPTION Class HorseTv
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1093525414?ticket=3A9A60F58F2E01E8D930B0F97F44381A69B5DCA2&profile=pass
#DESCRIPTION Bike Channel
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1923781688?ticket=69F72C464AB91B7CF3F6B5C1C3369DD5C1128268&profile=pass
#DESCRIPTION Caccia e PESCA
#SERVICE 1:0:1:0:0:0:0:0:0:0:http://localhost:9981
#DESCRIPTION ---------- CINEMA ----------
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F226900078?ticket=5E67AFC9D8A67F3E22FABD601B72107603A18FD5&profile=pass
#DESCRIPTION Cinema Max +1
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1648682411?ticket=4AF483F5E7AB42D26286E8B0A416403425D01292&profile=pass
#DESCRIPTION Cinema Passion
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1481309570?ticket=C625F01DFD63285FC2E1F950259B1C224AAEC99A&profile=pass
#DESCRIPTION Cinema Classics
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F549117508?ticket=D340CE31593E04F062F1B7FE419E548E3E7D1EC6&profile=pass
#DESCRIPTION Cinema +1
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F475194720?ticket=A655CAA63FD15DD607D73C7599D0993931823F62&profile=pass
#DESCRIPTION Cinema Cult
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F450591259?ticket=59F8B63F7D8A5E6BBF9E5141EA20F19FDE30874D&profile=pass
#DESCRIPTION Cinema 1
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F203150933?ticket=F95DD71AC3F2DE1F22E7B62398D80DE4C6DA6CA3&profile=pass
#DESCRIPTION Cinema Comedy
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F935764126?ticket=C54DDCB9381C9D43AAB1B52EB93981C6A14E4F42&profile=pass
#DESCRIPTION Cinema +24
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1091311045?ticket=B4998C48C72DB02C1F712E17AFA06221621DFB02&profile=pass
#DESCRIPTION Cinema Family
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1463045292?ticket=9521F17EA8F1740DF4E06D00641D4181FB9751BE&profile=pass
#DESCRIPTION Cinema Hits
#SERVICE 1:0:0:0:0:0:0:0:0:0:http%3A%2F%2Flocalhost%3A9981%2Fstream%2Fchannelid%2F1356767999?ticket=DF46B9AFC4B72A965D7C3A13691B3C6E81F55D84&profile=pass
#DESCRIPTION Cinema Max

#5

Updated by Jaroslav Kysela over 9 years ago

I don't like your implementation, but I take the idea. The bouquet like yours (including tag/channel sorting) is available using http://ip:9981/playlist/e2/tags url...

#6

Updated by Alfio Saitta over 9 years ago

Really great job. Mine was just an old implementation updated to work with the last commit.

A very useful thing would be to export the various data of each channel, pid, sid, etc etc.
This allows some devices to download the EPG and Picons autonomously.

The right data from tvh picons (picon://1_0_1_2B60_19C8_FBFF_820000_0_0_0.png), can be applied to the e2 playlist

#SERVICE 1:0:1:2B60:19C8:FBFF:820000:0:0:0:http%3A%2F%2Flocalhost.....
#DESCRIPTION Cinema Max

#7

Updated by saen acro over 9 years ago

If some one put in web interface both type of playlist will be great
also http://tvheadend.org/issues/2257

Also available in: Atom PDF