Changeset 41291


Ignore:
Timestamp:
Nov 25, 2017, 10:29:13 PM (2 years ago)
Author:
obi
Message:

update tithek add hlsdl support

Location:
titan
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • titan/mediathek/localhoster/hoster.sh

    r41279 r41291  
    99
    1010#FILENAME="`echo $SRC | tr '/' '\n' | tail -n1 | sed 's/.sh//'` $INPUT $PAGE $NEXT"
    11 FILENAME="`echo $INPUT | sed -e 's/\&\+/./g' -e 's#\/\+#.#g' -e 's/\?\+/./g' -e 's/;\+/./g' -e 's/=\+/./g' -e 's/ \+/./g' -e 's/\.\+/./g'`"
     11FILENAME="`echo $INPUT | sed -e 's/\&\+/./g' -e 's#\/\+#.#g' -e 's/\?\+/./g' -e 's/:\+/./g' -e 's/;\+/./g' -e 's/=\+/./g' -e 's/ \+/./g' -e 's/\.\+/./g'`"
    1212PICNAME=`echo $FILENAME`
    1313
     
    1515        FILENAME=none
    1616fi
     17
    1718
    1819ARCH=`cat /etc/.arch`
     
    2021TMP=/tmp/localcache
    2122CMD=/tmp/localhoster
     23BIN="$CMD"/bin/python."$ARCH"
     24HLSBIN="$CMD"/bin/hlsdl."$ARCH"
    2225#USERAGENT='Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0'
    2326USERAGENT='Mozilla%2F5.0+%28Windows+NT+6.3%3B+rv%3A36.0%29+Gecko%2F20100101+Firefox%2F36.0'
     
    2730youtubebin="$CMD/lib/youtube_dl/__main__.py --no-check-certificate --cookies /mnt/network/cookies --user-agent $USERAGENT --format mp4 --restrict-filenames --ignore-errors -g"
    2831youtubebinbg="$CMD/lib/youtube_dl/__main__.py --no-check-certificate --cookies /mnt/network/cookies --user-agent $USERAGENT --format mp4 --restrict-filenames --ignore-errors --output"
     32hlsdlbg="$HLSBIN -u $USERAGENT -o"
     33
    2934export PYTHONHOME=/tmp/localhoster
    3035export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/localhoster/lib
     
    3641
    3742wgetbin="wget -q -T2"
    38 
    39 BIN="$CMD"/bin/python."$ARCH"
    4043
    4144if [ ! -e "/tmp/localhoster/lib/python2.7/lib-dynload" ] && [ -e /tmp/localhoster/lib/python2.7/lib-dynload."$ARCH" ];then
     
    321324#       $BIN $CMD/lib/youtube_dl/__main__.py --no-check-certificate --cookies /mnt/network/cookies --user-agent "$USERAGENT" --format mp4 --restrict-filenames --ignore-errors -g "$INPUT" > /tmp/youtube_dl.streamlink.log 2>&1
    322325#       cat /tmp/youtube_dl.streamlink.log | tail -n1
    323         $BIN $youtubebin "$INPUT"
     326        mkdir $TMP > /dev/null 2>&1
     327
     328        echo "$BIN $youtubebin $INPUT" > /tmp/.last_hoster_youtube_dl.log
     329
     330        $BIN $youtubebin "$INPUT" > $TMP/$TYPE.$hoster.$FILENAME.streamlist
     331        echo $TMP/$TYPE.$hoster.$FILENAME.streamlist
    324332}
    325333
     
    330338#       echo "$URL" >> /tmp/.last_hoster_youtube_dlbg.log
    331339#       echo $URL
    332         $BIN $youtubebinbg $DEST $INPUT
    333 }
     340        mkdir $TMP > /dev/null 2>&1
     341
     342        echo "$BIN $youtubebinbg $DEST $INPUT" > /tmp/.last_hoster_$TYPE.log
     343        $BIN $youtubebinbg "$DEST" "$INPUT" >> /tmp/.last_hoster_$TYPE.log
     344#       echo $TMP/$TYPE.$hoster.$FILENAME.streamlist
     345}
     346
     347hlsdl()
     348{
     349        mkdir $TMP > /dev/null 2>&1
     350
     351        echo "$HLSBIN $hlsdlbg $DEST $INPUT" > /tmp/.last_hoster_$TYPE.log
     352
     353        REFERER=$(echo "$INPUT" | sed -nr 's/.*Referer=([^=]+)&.*/\1/p')
     354        if [ -z "$REFERER" ];then
     355                REFERER=$(echo "$INPUT" | sed -nr 's/.*Referer=([^=]+).*/\1/p')
     356        fi
     357
     358        if [ ! -z "$REFERER" ];then
     359                REFERER="Referer: $REFERER"
     360        fi
     361
     362        TMPUSERAGENT=$(echo "$INPUT" | sed -nr 's/.*User-Agent=([^=]+)&.*/\1/p')
     363        if [ -z "$TMPUSERAGENT" ];then
     364                TMPUSERAGENT=$(echo "$INPUT" | sed -nr 's/.*User-Agent=([^=]+).*/\1/p')
     365        fi
     366        if [ ! -z "$TMPUSERAGENT" ];then
     367                USERAGENT=$TMPUSERAGENT
     368        fi
     369
     370        URL=$(echo "$INPUT" | tr '|' '\n' | head -n1)
     371
     372        echo $HLSBIN "$URL" -v -f -u "$USERAGENT" -h "$REFERER" -o "$DEST" >> /tmp/.last_hoster_$TYPE.log
     373        $HLSBIN "$URL" -v -f -u "$USERAGENT" -h "$REFERER" -o "$DEST" >> /tmp/.last_hoster_$TYPE.log
     374#       $HLSBIN "$URL" -v -u "$USERA" -h "$REFERER" -o "$DEST" >> /tmp/.last_hoster_$TYPE.log
     375
     376}
     377
    334378
    335379if [ "$TYPE" == "get" ];then
     
    381425fi
    382426
     427if [ "$TYPE" == "hlsdl" ];then
     428        echo  "$INPUT" > /tmp/.last_hoster_$TYPE_$hoster.log
     429        case $hoster in
     430                *) hlsdl $INPUT;;
     431        esac
     432fi
  • titan/plugins/tithek/tithek.c

    r40900 r41291  
    117117        python = 0;
    118118        ytbgdownload = 0;
     119        hlsbgdownload = 0;
    119120       
    120121//change markcolor
  • titan/plugins/tithek/tithek.h

    r41274 r41291  
    1515int python = 0;
    1616int ytbgdownload = 0;
     17int hlsbgdownload = 0;
    1718
    1819//flag 0        - menu
     
    14631464}
    14641465
     1466void backgroundhlsdl(char* link, char* filename)
     1467{
     1468        int ret = 0;
     1469        char *file = NULL, *cmd = NULL;
     1470
     1471        file = ostrcat(getconfig("rec_streampath", NULL), "/", 0, 0);
     1472        file = ostrcat(file, filename, 1, 0);
     1473
     1474        cmd = ostrcat("/tmp/localhoster/hoster.sh hlsdl \"", link, 0, 0);
     1475        cmd = ostrcat(cmd, "\" \"", 1, 0);
     1476        cmd = ostrcat(cmd, file, 1, 0);
     1477        cmd = ostrcat(cmd, "\" &", 1, 0);
     1478
     1479        printf("cmd: %s\n", cmd);
     1480        ret = system(cmd);
     1481        free(cmd), cmd = NULL;
     1482        if(ret == 1)
     1483                textbox(_("Message"), _("Can't start download.\nPlease try later."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
     1484        else
     1485                hlsbgdownload = 1;
     1486}
     1487
    14651488void backgrounddl(char* link, char* filename)
    14661489{
     
    15251548{
    15261549        int flag = 0;
     1550        int debuglevel = getconfigint("debuglevel", NULL);
    15271551        char* tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL;
    15281552        drawscreen(load, 0, 0);
     
    16301654        free(tmpstr); tmpstr = NULL;
    16311655        free(tmpstr2); tmpstr2 = NULL;
     1656
     1657        debug(10, "Streamurl check: %s", tmpstr1);
     1658        debug(99, "Streamurl check: %s", tmpstr1);
     1659        tmpstr = ostrcat(tmpstr1, NULL, 0, 0);
     1660        tmpstr1 = list_hoster_streams(tmpstr);
     1661        if(ostrcmp(tmpstr, tmpstr1) != 0)
     1662        {
     1663                debug(10, "Streamurl changed to: %s", tmpstr1);
     1664                debug(99, "Streamurl changed to: %s", tmpstr1);
     1665        }
     1666        else
     1667        {
     1668                debug(10, "Streamurl check ok: %s", tmpstr1);
     1669                debug(99, "Streamurl check ok: %s", tmpstr1);
     1670        }
     1671
     1672        free(tmpstr), tmpstr = NULL;
    16321673
    16331674        if(ostrstr(title, "Internet Radio") != NULL)
     
    17511792                                }
    17521793
     1794                                if(python == 1 && ostrstr(tmpstr1, "hls") != NULL && file_exist(getconfig("rec_streampath", NULL)) && (file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack")))
     1795                                        addmenulist(&mlist, "Download Full File (hlsdl)", _("Download Full File (hlsdl)"), NULL, 0, 0);
     1796
    17531797                                if(python == 1 && file_exist(getconfig("rec_streampath", NULL)) && (file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack")))
    1754                                         addmenulist(&mlist, "Download via Youtube_DL (background)", _("Download Full File (youtube_dl)"), NULL, 0, 0);
     1798                                        addmenulist(&mlist, "Download Full File (youtube_dl)", _("Download Full File (youtube_dl)"), NULL, 0, 0);
     1799
    17551800                        }
    17561801                }
     
    18501895                        free(search), search = NULL;
    18511896                }
    1852                 else if(ostrcmp(keyconf, "Download via Youtube_DL (background)") == 0)
     1897                else if(ostrcmp(keyconf, "Download Full File (youtube_dl)") == 0)
    18531898                {
    18541899                        char* search = textinput(_("Filename"), filename);
    18551900                        if(search != NULL)
    18561901                                backgroundytdl(tmpstr1, search);
     1902                        free(search), search = NULL;
     1903                }
     1904                else if(ostrcmp(keyconf, "Download Full File (hlsdl)") == 0)
     1905                {
     1906                        char* search = textinput(_("Filename"), filename);
     1907                        if(search != NULL)
     1908                                backgroundhlsdl(tmpstr1, search);
    18571909                        free(search), search = NULL;
    18581910                }
     
    26752727                freetithek();
    26762728                delallfiles("/tmp/tithek", NULL);
    2677                 if(ytbgdownload == 0)
     2729                if(ytbgdownload == 0 && hlsbgdownload == 0)
    26782730                        system("rm -rf /tmp/localhoster");
    26792731                system("rm -rf /tmp/localparser");
  • titan/plugins/tithek/tithek_global.h

    r41288 r41291  
    77{
    88        debug(99, "url: %s", url);
    9         int debuglevel = getconfigint("debuglevel", NULL);
    109        char* streamurl = NULL, *tmplink = NULL, *tmpstr = NULL;
    1110        struct skin* load = getscreen("loading");
     
    218217        }
    219218
    220         debug(99, "Streamurl5: %s", streamurl);
     219        debug(99, "Streamurl1: %s", streamurl);
    221220
    222221        streamurl = string_replace_all("amp;", "", streamurl, 1);
    223         debug(99, "Streamurl6: %s", streamurl);
     222        debug(99, "Streamurl4: %s", streamurl);
    224223
    225224        free(tmplink), tmplink = NULL;
    226         free(tmpstr), tmpstr = NULL;
    227 
    228 //      printf("streamurl1: %s\n", streamurl);
    229         if(debuglevel != 99)
    230                 printf("Streamurl1: %s\n", streamurl);
    231         tmpstr = ostrcat(streamurl, NULL, 0, 0);
    232         streamurl = list_hoster_streams(tmpstr);
    233         if(debuglevel != 99)
    234                 printf("Streamurl2: %s\n", streamurl);
    235         debug(99, "Streamurl7: %s", streamurl);
    236 
    237         free(tmpstr), tmpstr = NULL;
    238 
    239225/*
    240226        if(ostrncmp("http", streamurl, 4) && ostrncmp("rtmp", streamurl, 4) && ostrncmp("mms", streamurl, 3) && ostrncmp("rtsp", streamurl, 4))
     
    13121298}
    13131299
    1314 char* list_hoster_streams(char* filename)
     1300char* list_hoster_streams(char* input)
    13151301{
     1302        char* streamurl = NULL, *tmpstr = NULL, *nummer = NULL, *title = NULL, *pic = NULL, *filename = NULL;
     1303
     1304        int count = 0, i = 0;   
     1305
     1306        filename = ostrcat(input, NULL, 0, 0);
    13161307
    13171308        if(ostrncmp("/tmp/", filename, 5) && ostrncmp("/mnt/", filename, 5))
    13181309                return filename;
    1319 
    1320 //      int debuglevel = getconfigint("debuglevel", NULL);
    1321         char* streamurl = NULL, *tmpstr = NULL, *nummer = NULL, *title = NULL, *pic = NULL;
    1322 
    1323         int count = 0, i = 0;   
     1310        else
     1311        {
     1312                debug(10, "Streamfile found: %s", input);
     1313                debug(99, "Streamfile found: %s", input);
     1314        }
    13241315
    13251316//      tmpstr = ostrcat(link, NULL, 0, 0);
     
    14041395        }
    14051396        free(tmpstr); tmpstr = NULL;
    1406 debug(99, "streamurl3 %s", streamurl);
     1397
    14071398        if(streamurl == NULL)
     1399        {
     1400                debug(10, "Streamfile choice canceld by USER set Streamurl to skip");
     1401                debug(99, "Streamfile choice canceld by USER set Streamurl to skip");
     1402
    14081403                streamurl = ostrcat("skip", NULL, 0, 0);
    1409 debug(99, "streamurl4 %s", streamurl);
     1404        }
    14101405
    14111406        return streamurl;
     
    14151410{
    14161411        debug(99, "link: %s", link);
    1417         int debuglevel = getconfigint("debuglevel", NULL);
    1418         int ret = 1, skip = 0;
     1412        int ret = 1;
    14191413        char* tmpstr = NULL, *streamurl = NULL;
    14201414
     
    14271421                tmpstr = string_replace_all("gethoster2 ", "", tmpstr, 1);
    14281422                streamurl = hoster(tmpstr);
    1429                 skip = 1;
    14301423        }
    14311424        else if(ostrstr(link, ".sh play ") != NULL)
    14321425                streamurl = ostrcat(tmpstr, NULL, 0, 0);
    14331426        else if(ostrstr(link, ".sh hoster ") != NULL)
    1434         {
    14351427                streamurl = hoster(tmpstr);
    1436                 skip = 1;
    1437         }
     1428
    14381429        free(tmpstr), tmpstr = NULL;
    1439 
    1440         if(skip == 0)
    1441         {
    1442                 if(debuglevel != 99)
    1443                         printf("Streamurl1: %s\n", streamurl);
    1444                 tmpstr = ostrcat(streamurl, NULL, 0, 0);
    1445                 streamurl = list_hoster_streams(tmpstr);
    1446                 if(debuglevel != 99)
    1447                         printf("Streamurl2: %s\n", streamurl);
    1448                 free(tmpstr), tmpstr = NULL;
    1449         }
    1450         debug(99, "streamurl2: %s", streamurl);
    1451 
    14521430        return streamurl;
    14531431}
  • titan/plugins/tithek/tithek_header.h

    r41274 r41291  
    1313char* localparser_hoster(char* link);
    1414int localparser_search(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag);
    15 char* list_hoster_streams(char* link);
     15char* list_hoster_streams(char* input);
    1616
    1717void titheklog(int debuglevel, char* name1, char* name2, char* name3, char* name4, char* content)
Note: See TracChangeset for help on using the changeset viewer.