Changeset 17969


Ignore:
Timestamp:
09/20/12 03:57:46 (12 years ago)
Author:
obi
Message:

[tithek] update youtube fix parser, add stream error msgs and allowed all supported formats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/plugins/tithek/tithek.h

    r17945 r17969  
    720720               
    721721                                                                                line = ostrcat(line, title, 1, 0);
    722                                                                                 line = ostrcat(line, "#http://www.youtube.com/watch?v=", 1, 0);
     722//                                                                              line = ostrcat(line, "#http://www.youtube.com/watch?v=", 1, 0);
     723                                                                                line = ostrcat(line, "#http://www.youtube.com/get_video_info?&video_id=", 1, 0);
    723724                                                                                line = ostrcat(line, id, 1, 0);
    724725                                                                                line = ostrcat(line, "#", 1, 0);
     
    927928                                }
    928929                                drawscreen(grid, 0, 0);
     930                                sleep(1);
    929931                        }                       
    930932                }
     
    944946}
    945947
    946 // flag 1 = youtube streamlink
    947 // flag 2 = rtlnow streamlinksrc
    948 // flag 3 = rtlnow streamlink
    949 // flag 4 = myvideo streamlink
    950 // flag 5 = kinox streamlink
     948// flag 1 = youtube
     949// flag 2 = rtlnow
     950// flag 3 = rtlnow
     951// flag 4 = myvideo
     952// flag 5 = kinox putlocker/ sockshare
     953// flag 6 = kinox filenuke
     954// flag 7 = youtube2
     955
    951956char* getstreamurl(char* link, char* url, char* name, int flag)
    952957{
    953958        debug(99, "link(%d): %s", flag, link);
    954         char* ip = NULL, *pos = NULL, *path = NULL, *pageUrl = NULL, *playpath = NULL, *video_id = NULL, *source = NULL, *streamurl = NULL;
     959        char* ip = NULL, *pos = NULL, *path = NULL, *pageUrl = NULL, *playpath = NULL, *video_id = NULL, *source = NULL, *streamurl = NULL, *title = NULL;
    955960
    956961        if(flag == 4)
     
    10411046        if(flag == 1)
    10421047        {
    1043                 tmpstr = string_resub("\": \"url=", "\", \"", tmpstr, 0);
    1044        
    1045                 while(ostrstr(tmpstr, ",url=") != NULL)
    1046                         tmpstr = string_replace(",url=", "\nurl=", tmpstr, 1);
    1047        
     1048                writesys("/var/usr/local/share/titan/plugins/tithek/cache_org", tmpstr, 0);
     1049//              printf("path %s\n", path);
     1050
    10481051                tmpstr = string_decode(tmpstr, 0);
    1049        
    1050                 int count = 0;
    1051                 int i = 0;
    1052                 struct splitstr* ret1 = NULL;
    1053                 ret1 = strsplit(tmpstr, "\n", &count);
    1054                 if(ret1 != NULL)
    1055                 {
    1056                         int max = count;
    1057                         for(i = 0; i < max; i++)
     1052                writesys("/var/usr/local/share/titan/plugins/tithek/cache_decode", tmpstr, 0);
     1053
     1054
     1055                tmpstr = string_decode(tmpstr, 0);
     1056                writesys("/var/usr/local/share/titan/plugins/tithek/cache_decode2", tmpstr, 0);
     1057
     1058                tmpstr = string_decode(tmpstr, 0);
     1059                writesys("/var/usr/local/share/titan/plugins/tithek/cache_decode3", tmpstr, 0);
     1060
     1061                if(ostrstr(tmpstr, "status=fail&") == NULL)
     1062                {
     1063                        tmpstr = string_resub("&url_encoded_fmt_stream_map=url=", "endscreen_module", tmpstr, 0);
     1064                        writesys("/var/usr/local/share/titan/plugins/tithek/cache_resub", tmpstr, 0);
     1065               
     1066                        while(ostrstr(tmpstr, ",url=") != NULL)
     1067                                tmpstr = string_replace(",url=", "\n", tmpstr, 1);
     1068       
     1069                        writesys("/var/usr/local/share/titan/plugins/tithek/cache_replace", tmpstr, 0);
     1070                               
     1071                        struct menulist* mlist = NULL, *mbox = NULL;
     1072                        int count = 0;
     1073                        int i = 0;
     1074                        struct splitstr* ret1 = NULL;
     1075                        ret1 = strsplit(tmpstr, "\n", &count);
     1076                        if(ret1 != NULL)
    10581077                        {
    1059                                 if(ostrstr(ret1[i].part, "type=video/mp4") != NULL)
    1060                                 {
    1061                                         streamurl = ostrcat(streamurl, ret1[i].part, 1, 0);
    1062                                         int count2 = 0;
    1063                                         struct splitstr* ret2 = NULL;
    1064                                         ret2 = strsplit(ret1[i].part, "+", &count2);
    1065                                         if(ret2 != NULL)
     1078                                int max = count;
     1079                                for(i = 0; i < max; i++)
     1080                                {
     1081                                        printf("(%d) %s\n",i, (ret1[i]).part);
     1082                                        if(ostrstr(ret1[i].part, "type=video/webm") == NULL)
    10661083                                        {
    1067                                                 free(streamurl);
    1068                                                 streamurl = ostrcat("", ret2[0].part, 0, 0);
    1069                                                 free(ret2); ret2 = NULL;
     1084                                                streamurl = ostrcat((ret1[i]).part, NULL, 0, 0);
     1085                                                if(ostrstr(ret1[i].part, "video/x-flv") != NULL)
     1086                                                {
     1087                                                        ret1[i].part = string_replace("video/x-flv", "video/x-flv\n", ret1[i].part, 0);
     1088                                                        int count2 = 0;
     1089                                                        struct splitstr* ret2 = NULL;
     1090                                                        ret2 = strsplit(ret1[i].part, "\n", &count2);
     1091                                                        if(ret2 != NULL)
     1092                                                        {
     1093                                                                free(streamurl), streamurl = NULL;
     1094                                                                streamurl = ostrcat(ret2[0].part, NULL, 0, 0);
     1095                                                        }
     1096                                                        free(ret2); ret2 = NULL;                                       
     1097                                                }
     1098                                                else if(ostrstr(ret1[i].part, "+") != NULL)
     1099                                                {
     1100                                                        int count2 = 0;
     1101                                                        struct splitstr* ret2 = NULL;
     1102                                                        ret2 = strsplit(ret1[i].part, "+", &count2);
     1103                                                        if(ret2 != NULL)
     1104                                                        {
     1105                                                                free(streamurl), streamurl = NULL;
     1106                                                                streamurl = ostrcat(ret2[0].part, NULL, 0, 0);
     1107                                                        }
     1108                                                        free(ret2); ret2 = NULL;                                       
     1109                                                }
     1110                                               
     1111                                                if(ostrstr(ret1[i].part, "itag=85") != NULL)
     1112                                                        title = ostrcat("MP4 520p H.264 3D", NULL, 0, 0);
     1113                                                else if(ostrstr(ret1[i].part, "itag=84") != NULL)
     1114                                                        title = ostrcat("MP4 720p H.264 3D", NULL, 0, 0);
     1115                                                else if(ostrstr(ret1[i].part, "itag=83") != NULL)
     1116                                                        title = ostrcat("MP4 240p H.264 3D", NULL, 0, 0);
     1117                                                else if(ostrstr(ret1[i].part, "itag=82") != NULL)
     1118                                                        title = ostrcat("MP4 360p H.264 3D", NULL, 0, 0);
     1119                                                else if(ostrstr(ret1[i].part, "itag=38") != NULL)
     1120                                                        title = ostrcat("MP4 3072p H.264 High", NULL, 0, 0);
     1121                                                else if(ostrstr(ret1[i].part, "itag=37") != NULL)
     1122                                                        title = ostrcat("MP4 1080p H.264 High", NULL, 0, 0);
     1123                                                else if(ostrstr(ret1[i].part, "itag=22") != NULL)
     1124                                                        title = ostrcat("MP4 720p H.264 High", NULL, 0, 0);
     1125                                                else if(ostrstr(ret1[i].part, "itag=18") != NULL)
     1126                                                        title = ostrcat("MP4 360p H.264 Baseline", NULL, 0, 0);                                                                                         
     1127                                                else if(ostrstr(ret1[i].part, "itag=6") != NULL)
     1128                                                        title = ostrcat("FLV 270p Sorenson H.263", NULL, 0, 0);
     1129                                                else if(ostrstr(ret1[i].part, "itag=5") != NULL)
     1130                                                        title = ostrcat("FLV 240p Sorenson H.263", NULL, 0, 0);
     1131                                                else if(ostrstr(ret1[i].part, "itag=35") != NULL)
     1132                                                        title = ostrcat("FLV 480p H.264 Main", NULL, 0, 0);
     1133                                                else if(ostrstr(ret1[i].part, "itag=34") != NULL)
     1134                                                        title = ostrcat("FLV 360p H.264 Main", NULL, 0, 0);                                                                                                                                             
     1135                                                else if(ostrstr(ret1[i].part, "itag=36") != NULL)
     1136                                                        title = ostrcat("3GP 240p MPEG-4 Visual Simple", NULL, 0, 0);
     1137                                                else if(ostrstr(ret1[i].part, "itag=17") != NULL)
     1138                                                        title = ostrcat("3GP 144p MPEG-4 Visual Simple", NULL, 0, 0);
     1139                                               
     1140                                                if(title == NULL)
     1141                                                        title = ostrcat(_("unknown"), NULL, 0, 0);
     1142                                                                                                                                                                                                                                                                                                       
     1143                                                addmenulist(&mlist, title, streamurl, NULL, 0, 0);
     1144                                                free(title), title = NULL;                                     
     1145                                                free(streamurl), streamurl = NULL;
    10701146                                        }
    10711147                                }
     1148                                free(ret1); ret1 = NULL;                       
    10721149                        }
    1073                         free(ret1); ret1 = NULL;
    1074                        
    1075                         streamurl = string_replace("url=", "", streamurl, 1);
     1150       
     1151                        if(mlist != NULL)
     1152                        {
     1153                                mbox = menulistbox(mlist, NULL, NULL, NULL, NULL, 1, 0);
     1154                                if(mbox != NULL)
     1155                                {
     1156                                        free(streamurl), streamurl = NULL;
     1157               
     1158                                        debug(99, "mbox->name %s", mbox->name);
     1159                                        debug(99, "mbox->text %s", mbox->text);
     1160                                        streamurl = ostrcat(mbox->text, NULL, 0, 0);
     1161               
     1162                                }
     1163                        }
     1164/*
     1165                        else
     1166                        {
     1167        // videos not alloed in this country or outside youtube, lik has http error 403...             
     1168        //                      link = string_replace("http://www.youtube.com/get_video_info?&video_id=", "http://www.youtube.com/watch?v=", link, 0);
     1169        //                      streamurl = getstreamurl(link, url, name, 7);
     1170        //                      free(tmpstr); tmpstr = NULL;
     1171                        }
     1172*/
     1173                }
     1174                else
     1175                {       
     1176                printf("hhhhhhhh\n");           
     1177                        tmpstr = string_resub("&reason=", "&errordetail", tmpstr, 1);
     1178                        tmpstr = string_replace_all("+", " ", tmpstr, 1);
     1179                        tmpstr = string_replace_all(", ", "\n", tmpstr, 1);
     1180                        tmpstr = string_replace("wiedergegeben", "\nwiedergegeben ", tmpstr, 1);
     1181                        tmpstr = string_replace("<br/><u><a href='", "\n\n", tmpstr, 1);
     1182                        tmpstr = string_replace("' target='_blank'>", "\n", tmpstr, 1);
     1183                        tmpstr = string_replace("</a></u>", "\n", tmpstr, 1);                   
     1184                        textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0);
    10761185                }
    10771186                free(tmpstr); tmpstr = NULL;
     1187
    10781188        }
    10791189        else if(flag == 2)
     
    10901200        else if(flag == 3)
    10911201        {
    1092 //              string_resub("delivery=\"streaming\"><![CDATA[", "]]></filename>", tmpstr, 0);
    10931202                tmpstr = string_resub("rtmpe://", ".f4v", tmpstr, 0);
    10941203                char* tmpstr9 = NULL;
     
    11561265                debug(99, "streamurl: %s", streamurl);
    11571266        }
    1158         if(flag == 4)
    1159         {
    1160 // somtimes segfault
    1161 //              writesys("/tmp/tithek/list", tmpstr, 0);
     1267        else if(flag == 4)
     1268        {
    11621269                char* tmpstr_uni = NULL;
    11631270                char* b64 = NULL;
     
    11971304                        rc4(tmpstr_uni, hlen, key, klen);
    11981305
    1199                         debug(99, "encrypted=%s", tmpstr_uni);         
    1200 // somtimes segfault
    1201 //                      writesys("/tmp/tithek/list_key", tmpstr_uni, 1);                       
    1202 
     1306                        debug(99, "encrypted=%s", tmpstr_uni);
    12031307                        debug(99, "pageUrl: %s\n", pageUrl);
    12041308                        debug(99, "playpath: %s\n", playpath);
     
    12501354                free(pageUrl); pageUrl = NULL;         
    12511355                free(playpath); playpath = NULL;
    1252                 debug(99, "streamurl: %s", streamurl);
    1253         }
     1356        }
     1357        else if(flag == 7)
     1358        {
     1359        printf("in 77777777777777\n");
     1360                writesys("/var/usr/local/share/titan/plugins/tithek/1cache_org", tmpstr, 0);
     1361
     1362                tmpstr = string_decode(tmpstr, 0);
     1363                writesys("/var/usr/local/share/titan/plugins/tithek/1cache_decode", tmpstr, 0);
     1364
     1365                tmpstr = string_decode(tmpstr, 0);
     1366                writesys("/var/usr/local/share/titan/plugins/tithek/1cache_decode2", tmpstr, 0);
     1367
     1368
     1369//              tmpstr = string_resub("\": \"url=", "\", \"", tmpstr, 0);
     1370                tmpstr = string_resub("var swf = \"", ".innerHTML = swf", tmpstr, 0);
     1371
     1372               
     1373                writesys("/var/usr/local/share/titan/plugins/tithek/1cache_resub", tmpstr, 0);
     1374       
     1375                while(ostrstr(tmpstr, "&url=") != NULL)
     1376                        tmpstr = string_replace("&url=", "\nurl=", tmpstr, 1);
     1377
     1378                writesys("/var/usr/local/share/titan/plugins/tithek/1cache_replace", tmpstr, 0);
     1379                       
     1380       
     1381                int count = 0;
     1382                int i = 0;
     1383                struct splitstr* ret1 = NULL;
     1384                ret1 = strsplit(tmpstr, "\n", &count);
     1385                if(ret1 != NULL)
     1386                {
     1387                        int max = count;
     1388                        for(i = 0; i < max; i++)
     1389                        {
     1390                                if(ostrstr(ret1[i].part, "type=video/mp4") != NULL)
     1391                                {
     1392                                        streamurl = ostrcat(streamurl, ret1[i].part, 1, 0);
     1393                                        int count2 = 0;
     1394                                        struct splitstr* ret2 = NULL;
     1395                                        ret2 = strsplit(ret1[i].part, "+", &count2);
     1396                                        if(ret2 != NULL)
     1397                                        {
     1398                                                free(streamurl);
     1399                                                streamurl = ostrcat("", ret2[0].part, 0, 0);
     1400                                                free(ret2); ret2 = NULL;
     1401                                        }
     1402                                }
     1403                        }
     1404                        free(ret1); ret1 = NULL;
     1405                       
     1406                        streamurl = string_replace("url=", "", streamurl, 1);
     1407                }
     1408                free(tmpstr); tmpstr = NULL;
     1409                writesys("/var/usr/local/share/titan/plugins/tithek/1cache_streamurl", streamurl, 0);
     1410
     1411                streamurl = string_decode(streamurl, 0);
     1412                writesys("/var/usr/local/share/titan/plugins/tithek/1cache_streamurl1", streamurl, 0);
     1413
     1414                streamurl = string_replace("&gcr=de", "", streamurl, 1);
     1415                writesys("/var/usr/local/share/titan/plugins/tithek/1cache_streamurl2", streamurl, 0);
     1416               
     1417                return streamurl;
     1418        }
     1419
     1420        debug(99, "streamurl2: %s", streamurl);
    12541421        return streamurl;
    12551422}
Note: See TracChangeset for help on using the changeset viewer.