Changeset 36117


Ignore:
Timestamp:
11/08/15 19:49:12 (8 years ago)
Author:
obi
Message:

tithek add streamlive mediathek

Location:
titan
Files:
1 added
4 edited

Legend:

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

    r36083 r36117  
    1111int titheksolarmovie = 0;
    1212int tithekmlehd = 0;
    13 int amazonlogin = 0;
    1413
    1514//flag 0        - menu
    1615//flag 1        - menu pay hidden tithek_pay=0/1 0=hidden
    1716//flag 2        - http (default streamurl)
    18 //flag 3        - http radio
     17//flag 3        - menu cover
    1918//flag 4        - youtube
    2019//flag 5        - nowtv //rtl2now
     
    9089//flag 75   - watchmovies local search
    9190//flag 75   - amazon
    92 //flag 76   - amazon movie search
    93 //flag 77   - amazon series search
    94 //flag 78   - amazon series listed search
    95 //flag 79   - amazon watchlist movie
    96 //flag 80   - amazon watchlist tv
    97 //flag 81   - amazon popularity.rank movie
    98 //flag 82   - amazon next page
    99 //flag 83   - amazon popularity.rank tv
    100 //flag 84   - amazon popularity.kids movie
    101 //flag 85   - amazon popularity.kids tv
    102 //flag 86   - amazon currently movie
    103 //flag 87   - amazon genre movie
    104 //flag 88   - amazon genre movie listed
    105 //flag 89   - amazon genre tv
    106 //flag 90   - amazon genre tv listed
    107 
     91//flag 76   - amazon search
     92//flag 77   - amazon local search
    10893//flag 100  - all local search
    10994//flag 1000 - menu pincode
     
    242227                cmd = ostrcat(cmd, "rmovi", 1, 0);
    243228                cmd = ostrcat(cmd, "e.", 1, 0);
    244                 cmd = ostrcat(cmd, "ph", 1, 0);
     229                cmd = ostrcat(cmd, "is", 1, 0);
    245230               
    246231                for(i = 0; i < 3; i++)
     
    588573char* tithekdownload(char* link, char* localname, char* pw, int pic, int flag)
    589574{
    590         int ret = 1, port = 80, timeout = 10000, ssl = 0;
     575        int ret = 1, port = 80, timeout = 10000;
    591576        char* ip = NULL, *pos = NULL, *path = NULL;
    592577        char* tmpstr = NULL, *localfile = NULL;
    593578
    594579        if(link == NULL) return NULL;
    595         if(ostrncmp("http://", link, 7) && ostrncmp("https://", link, 8)) return NULL;
    596 
    597         if(!ostrncmp("https://", link, 8))
    598                 ssl = 1;
    599         else
    600         {
    601                 ip = string_replace("http://", "", (char*)link, 0);
    602        
    603                 // tithek security
    604                 ip = string_replace_all("imageshack.us/md/up/grd/", "atemio.dyndns.tv/", ip, 1);
    605        
    606                 ip = string_replace_all("kinox.to", "kinox.me", ip, 1);
    607                 //ip = string_replace_all("movie4k.to", "movie4k.me", ip, 1);
    608        
    609                 if(ip != NULL)
    610                         pos = strchr(ip, '/');
    611                 if(pos != NULL)
    612                 {
    613                         pos[0] = '\0';
    614                         path = pos + 1;
    615                 }
    616        
    617                 if(ostrstr(ip, ":") != NULL)
    618                 {
    619                         ip = oregex("http://(.*):.*", link);
    620                         port = atoi(oregex("http://.*:(.*)/.*", link));
    621                 }
     580        if(ostrncmp("http://", link, 7)) return NULL;
     581
     582        ip = string_replace("http://", "", (char*)link, 0);
     583        // tithek security
     584        ip = string_replace_all("imageshack.us/md/up/grd/", "atemio.dyndns.tv/", ip, 1);
     585
     586        ip = string_replace_all("kinox.to", "kinox.me", ip, 1);
     587        //ip = string_replace_all("movie4k.to", "movie4k.me", ip, 1);
     588
     589        if(ip != NULL)
     590                pos = strchr(ip, '/');
     591        if(pos != NULL)
     592        {
     593                pos[0] = '\0';
     594                path = pos + 1;
     595        }
     596
     597        if(ostrstr(ip, ":") != NULL)
     598        {
     599                ip = oregex("http://(.*):.*", link);
     600                port = atoi(oregex("http://.*:(.*)/.*", link));
    622601        }
    623602
     
    640619                        localfile = ostrcat(localfile, localname, 1, 0);
    641620        }
    642         free(tmpstr); tmpstr = NULL;
    643621
    644622/*
     
    651629        debug(99, "path: %s", path);
    652630        debug(99, "localfile: %s", localfile);
    653         debug(99, "pw: %s", pw);
     631//      debug(99, "pw: %s", pw);
    654632        debug(99, "---------------------------------------");
    655633*/
     
    660638                        if(pic == 1)
    661639                        {
    662                                 if(ssl == 1)
    663                                         gethttps(link, localfile, NULL, NULL, NULL, NULL, 0);
    664                                 else if(tithekdownloadcount >= 24) //start max 24 threads
     640                                if(tithekdownloadcount >= 24) //start max 24 threads
    665641                                        gethttp(ip, path, port, localfile, pw, timeout, NULL, 0);
    666642                                else
     
    718694        }
    719695
    720 //      amazon_init(titheklink, tithekfile);
    721 
    722696        delmarkedscreennodes(grid, 1);
    723697        freetithek();
     
    783757        }
    784758       
    785         if((getconfigint("tithek_cover", NULL) == 1 && flag == 0) || (getconfigint("tithek_view", NULL) == 1 && flag != 0))
     759        if((getconfigint("tithek_cover", NULL) == 1 && flag == 3) || (getconfigint("tithek_view", NULL) == 1 && flag != 3))
    786760        {
    787761                height = 500;
     
    794768        }
    795769
    796         if((getconfigint("tithek_cover", NULL) == 2 && flag == 0) || (getconfigint("tithek_view", NULL) == 2 && flag != 0))
     770        if((getconfigint("tithek_cover", NULL) == 2 && flag == 3) || (getconfigint("tithek_view", NULL) == 2 && flag != 3))
    797771        {
    798772                height = 280;
     
    805779        }
    806780
    807         if((getconfigint("tithek_cover", NULL) == 3 && flag == 0) || (getconfigint("tithek_view", NULL) == 3 && flag != 0))
     781        if((getconfigint("tithek_cover", NULL) == 3 && flag == 3) || (getconfigint("tithek_view", NULL) == 3 && flag != 3))
    808782        {
    809783                height = 180;
     
    816790        }
    817791
    818         if((getconfigint("tithek_cover", NULL) == 4 && flag == 0) || (getconfigint("tithek_view", NULL) == 4 && flag != 0))
     792        if((getconfigint("tithek_cover", NULL) == 4 && flag == 3) || (getconfigint("tithek_view", NULL) == 4 && flag != 3))
    819793        {
    820794                height = 140;
     
    827801        }
    828802
    829         if((getconfigint("tithek_cover", NULL) == 5 && flag == 0) || (getconfigint("tithek_view", NULL) == 5 && flag != 0))
     803        if((getconfigint("tithek_cover", NULL) == 5 && flag == 3) || (getconfigint("tithek_view", NULL) == 5 && flag != 3))
    830804        {
    831805                height = 111;
     
    838812        }
    839813
    840         if((getconfigint("tithek_cover", NULL) == 6 && flag == 0) || (getconfigint("tithek_view", NULL) == 6 && flag != 0))
     814        if((getconfigint("tithek_cover", NULL) == 6 && flag == 3) || (getconfigint("tithek_view", NULL) == 6 && flag != 3))
    841815        {
    842816                height = 50;
     
    13261300                if(tmpstr != NULL) tmpstr1 = ostrcat(tmpstr, NULL, 0, 0);
    13271301        }                                               
    1328         else if(((struct tithek*)listbox->select->handle)->flag == 3)
    1329         {
    1330                 flag = 4;
    1331                 if(tmpstr != NULL) tmpstr1 = ostrcat(tmpstr, NULL, 0, 0);
    1332         }
    13331302        else if(((struct tithek*)listbox->select->handle)->flag == 4)
    13341303        {
     
    14151384                struct menulist* mlist = NULL, *mbox = NULL;
    14161385
    1417 #ifndef MIPSEL
    14181386                addmenulist(&mlist, "Streaming Playback (default)", _("Streaming Playback (default)"), NULL, 0, 0);
    1419 #else
    1420                 // mipsel work, disable http direct streams without buffer, after 3mins no memory (memleak in player.h ?)
    1421                 if(ostrncmp("http://", tmpstr1, 7))
    1422                         addmenulist(&mlist, "Streaming Playback (default)", _("Streaming Playback (default)"), NULL, 0, 0);
    1423 #endif
     1387
    14241388                if(!ostrncmp("http://", tmpstr1, 7))
    14251389                {
     
    14281392                        if(flag == 4)
    14291393                        {
    1430 //#ifdef EPLAYER3
    1431 //                              addmenulist(&mlist, "Streaming Playback Caching (1MB)", _("Streaming Playback Caching (1MB)"), NULL, 0, 0);
    1432 //#else
    1433 //                              // mipsel work for radio
    1434 //                              addmenulist(&mlist, "Streaming Playback (default)", _("Streaming Playback (default)"), NULL, 0, 0);
    1435 //#endif
     1394#ifdef EPLAYER3
     1395                                addmenulist(&mlist, "Streaming Playback Caching (1MB)", _("Streaming Playback Caching (1MB)"), NULL, 0, 0);
     1396#endif
    14361397                        }       
    14371398                        else if(!ostrncmp("http://", tmpstr1, 7))
     
    14471408                                if(file_exist(getconfig("rec_streampath", NULL)) && (file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack")))
    14481409                                {
    1449 /*
    14501410#ifndef EPLAYER3
    14511411                                        addmenulist(&mlist, "File Caching Playback (10MB / 120s)", _("File Caching Playback (10MB / 120s)"), NULL, 0, 0);
     
    14531413                                        addmenulist(&mlist, "File Caching Playback (30MB / 360s)", _("File Caching Playback (30MB / 360s)"), NULL, 0, 0);
    14541414#endif
    1455 */
    14561415                                        addmenulist(&mlist, "Download Full File", _("Download Full File"), NULL, 0, 0);
    14571416                                        addmenulist(&mlist, "Download Full File (background)", _("Download Full File (background)"), NULL, 0, 0);
     
    19861945                                clearscreen(grid);
    19871946
    1988                                 if(((struct tithek*)listbox->select->handle)->flag == 2 || ((struct tithek*)listbox->select->handle)->flag == 3 || ((struct tithek*)listbox->select->handle)->flag == 4 || ((struct tithek*)listbox->select->handle)->flag == 5 || ((struct tithek*)listbox->select->handle)->flag == 6 || ((struct tithek*)listbox->select->handle)->flag == 12 || ((struct tithek*)listbox->select->handle)->flag == 14 || ((struct tithek*)listbox->select->handle)->flag == 15 || ((struct tithek*)listbox->select->handle)->flag == 20 || ((struct tithek*)listbox->select->handle)->flag == 38 || ((struct tithek*)listbox->select->handle)->flag == 42 || ((struct tithek*)listbox->select->handle)->flag == 45 || ((struct tithek*)listbox->select->handle)->flag == 46 || ((struct tithek*)listbox->select->handle)->flag == 64 || ((struct tithek*)listbox->select->handle)->flag == 50 || ((struct tithek*)listbox->select->handle)->flag == 41 || ((struct tithek*)listbox->select->handle)->flag == 43 || ((struct tithek*)listbox->select->handle)->flag == 75)
     1947                                if(((struct tithek*)listbox->select->handle)->flag == 2 || ((struct tithek*)listbox->select->handle)->flag == 4 || ((struct tithek*)listbox->select->handle)->flag == 5 || ((struct tithek*)listbox->select->handle)->flag == 6 || ((struct tithek*)listbox->select->handle)->flag == 12 || ((struct tithek*)listbox->select->handle)->flag == 14 || ((struct tithek*)listbox->select->handle)->flag == 15 || ((struct tithek*)listbox->select->handle)->flag == 20 || ((struct tithek*)listbox->select->handle)->flag == 38 || ((struct tithek*)listbox->select->handle)->flag == 42 || ((struct tithek*)listbox->select->handle)->flag == 45 || ((struct tithek*)listbox->select->handle)->flag == 46 || ((struct tithek*)listbox->select->handle)->flag == 64 || ((struct tithek*)listbox->select->handle)->flag == 50 || ((struct tithek*)listbox->select->handle)->flag == 41 || ((struct tithek*)listbox->select->handle)->flag == 43 || ((struct tithek*)listbox->select->handle)->flag == 75)
    19891948                                {
    19901949                                        submenu(listbox, load, title);
     
    21692128                                {
    21702129                                        if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 0) == 0)
    2171                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2172                                 }
    2173                                 else if(((struct tithek*)listbox->select->handle)->flag == 77)
    2174                                 {
    2175                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 1) == 0)
    2176                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2177                                 }
    2178                                 else if(((struct tithek*)listbox->select->handle)->flag == 78)
    2179                                 {
    2180                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 2) == 0)
    2181                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2182                                 }
    2183                                 else if(((struct tithek*)listbox->select->handle)->flag == 79)
    2184                                 {
    2185                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 3) == 0)
    2186                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2187                                 }
    2188                                 else if(((struct tithek*)listbox->select->handle)->flag == 80)
    2189                                 {
    2190                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 4) == 0)
    2191                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2192                                 }
    2193                                 else if(((struct tithek*)listbox->select->handle)->flag == 81)
    2194                                 {
    2195                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 5) == 0)
    2196                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2197                                 }
    2198                                 else if(((struct tithek*)listbox->select->handle)->flag == 82)
    2199                                 {
    2200                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 6) == 0)
    2201                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2202                                 }
    2203                                 else if(((struct tithek*)listbox->select->handle)->flag == 83)
    2204                                 {
    2205                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 7) == 0)
    2206                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2207                                 }
    2208                                 else if(((struct tithek*)listbox->select->handle)->flag == 84)
    2209                                 {
    2210                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 8) == 0)
    2211                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2212                                 }
    2213                                 else if(((struct tithek*)listbox->select->handle)->flag == 85)
    2214                                 {
    2215                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 9) == 0)
    2216                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2217                                 }
    2218                                 else if(((struct tithek*)listbox->select->handle)->flag == 86)
    2219                                 {
    2220                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 10) == 0)
    2221                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2222                                 }
    2223                                 else if(((struct tithek*)listbox->select->handle)->flag == 87)
    2224                                 {
    2225                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 11) == 0)
    2226                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2227                                 }
    2228                                 else if(((struct tithek*)listbox->select->handle)->flag == 88)
    2229                                 {
    2230                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 12) == 0)
    2231                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2232                                 }
    2233                                 else if(((struct tithek*)listbox->select->handle)->flag == 89)
    2234                                 {
    2235                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 13) == 0)
    2236                                                 if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    2237                                 }
    2238                                 else if(((struct tithek*)listbox->select->handle)->flag == 90)
    2239                                 {
    2240                                         if(amazon_search(grid, listbox, countlabel, load, ((struct tithek*)listbox->select->handle)->link, ((struct tithek*)listbox->select->handle)->title, NULL, 14) == 0)
    22412130                                                if(screenlistbox(grid, listbox, countlabel, title, titheklink, &pagecount, &tithekexit, &oaktpage, &oaktline, &ogridcol, 0, 0) == 0) break;
    22422131                                }
     
    23272216        }
    23282217
    2329         amazon_deinit();
    2330 
    23312218        delmarkedscreennodes(grid, 1);
    23322219        delownerrc(grid);
  • titan/plugins/tithek/tithek_global.h

    r36093 r36117  
    44#include <curl/curl.h>
    55
     6struct MemoryStruct {
     7  char *memory;
     8  size_t size;
     9};
     10
     11static size_t
     12WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
     13{
     14  size_t realsize = size * nmemb;
     15  struct MemoryStruct *mem = (struct MemoryStruct *)userp;
     16 
     17  mem->memory = realloc(mem->memory, mem->size + realsize + 1);
     18  if(mem->memory == NULL) {
     19    /* out of memory! */
     20    printf("not enough memory (realloc returned NULL)\n");
     21    return 0;
     22  }
     23 
     24  memcpy(&(mem->memory[mem->size]), contents, realsize);
     25  mem->size += realsize;
     26  mem->memory[mem->size] = 0;
     27 
     28  return realsize;
     29}
     30
     31char* gethttps(char* url, char* data)
     32{
     33        debug(99, "url: %s", url);
     34
     35        int debuglevel = getconfigint("debuglevel", NULL);
     36       
     37        CURL *curl_handle;
     38        CURLcode res;
     39       
     40        struct MemoryStruct chunk;
     41       
     42        chunk.memory = malloc(1);  /* will be grown as needed by the realloc above */
     43        chunk.size = 0;    /* no data at this point */
     44       
     45        curl_global_init(CURL_GLOBAL_ALL);
     46       
     47        /* init the curl session */
     48        curl_handle = curl_easy_init();
     49        if(curl_handle)
     50        {
     51                /* specify URL to get */
     52                curl_easy_setopt(curl_handle, CURLOPT_URL, url);
     53                if(data == NULL)
     54                        curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1L);
     55                else
     56                        curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, data);
     57                curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1L);
     58                curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 5);
     59                curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 20);
     60                /* send all data to this function  */
     61                curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
     62                /* we pass our 'chunk' struct to the callback function */
     63                curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
     64                /* some servers don't like requests that are made without a user-agent field, so we provide one */
     65                curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
     66                curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
     67                curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L);
     68                if(debuglevel == 99)
     69                        curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
     70                curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, "/mnt/network/cookies");
     71                curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, "/mnt/network/cookies");
     72                curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
     73                curl_easy_setopt(curl_handle, CURLOPT_AUTOREFERER, 1L);
     74
     75                /* get it! */
     76                res = curl_easy_perform(curl_handle);
     77                /* check for errors */
     78                if(res != CURLE_OK)
     79                {
     80                        err("failed: %s", curl_easy_strerror(res));
     81                        printf("curl error\n");
     82                }
     83                else
     84                {
     85                        /*
     86                         * Now, our chunk.memory points to a memory block that is chunk.size
     87                         * bytes big and contains the remote file.
     88                         *
     89                         * Do something nice with it!
     90                         */
     91                        printf("%lu bytes retrieved\n", (long)chunk.size);
     92                }
     93               
     94                /* cleanup curl stuff */
     95                curl_easy_cleanup(curl_handle);
     96        }
     97        char* tmpstr = NULL;
     98        tmpstr = ostrcat(chunk.memory, NULL, 0, 0);
     99        free(chunk.memory);
     100        /* we're done with libcurl, so clean it up */
     101        curl_global_cleanup();
     102
     103        return tmpstr;
     104}
     105
     106char* getfilekey(char* w, char* i, char* s, char* e)
     107{
     108        char* ret = NULL;
     109
     110        if(w == NULL || i == NULL || s == NULL || e == NULL)
     111                return NULL;
     112
     113        int a = 0, b = 0, c = 0;
     114        int a1 = 0, b1 = 0;
     115
     116        int lw = strlen(w);
     117        int li = strlen(i);
     118        int ls = strlen(s);
     119       
     120        if(lw < 5 || li < 5 || ls < 5)
     121                return NULL;
     122
     123        char ca[lw + li + ls - 14];
     124        char cb[16];
     125
     126        ca[lw + li + ls - 15] = '\0';
     127        cb[15] = '\0';
     128       
     129        while(1)
     130        {
     131                if(a < 5)
     132                {
     133                        cb[b1] = w[a];
     134                        b1++;
     135                }
     136                else if(a < lw)
     137                {
     138                        ca[a1] = w[a];
     139                        a1++;
     140                }
     141                a++;
     142               
     143                if(b < 5)
     144                {
     145                        cb[b1] = i[b];
     146                        b1++;
     147                }
     148                else if(b < li)
     149                {
     150                        ca[a1] = i[b];
     151                        a1++;
     152                }
     153                b++;
     154               
     155                if(c < 5)
     156                {
     157                        cb[b1] = s[c];
     158                        b1++;
     159                }
     160                else if(c < ls)
     161                {
     162                        ca[a1] = s[c];
     163                        a1++;
     164                }
     165                c++;
     166               
     167                if(lw + li + ls == a1 + b1)
     168                        break;
     169        }
     170
     171        b = 0;
     172        int d = 0;
     173        char cc[a1 / 2 + 1];
     174        char casub[3] = {'\0'};
     175        cc[a1 / 2] = '\0';
     176       
     177        for(a = 0; a < a1; a += 2)
     178        {
     179                int c = -1;
     180               
     181                if(cb[b] % 2) c = 1;
     182
     183                casub[0] = ca[a];
     184                casub[1] = ca[a + 1];
     185
     186                cc[d] = strtol(casub, '\0', 36) - c;
     187                b++; d++;
     188                if(b >= b1) b = 0;
     189        }
     190
     191        char* r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL;
     192        char* pos = ostrstr(cc, ");}('");
     193        if(pos != NULL)
     194        {
     195                r1 = string_resub(");}('", "'", pos, 0);
     196                pos = ostrstr(pos + 5, ",'");
     197                if(pos != NULL)
     198                {
     199                        r2 = string_resub(",'", "'", pos, 0);
     200                        pos = ostrstr(pos + 2, ",'");
     201                        if(pos != NULL)
     202                        {
     203                                r3 = string_resub(",'", "'", pos, 0);
     204                                pos = ostrstr(pos + 2, ",'");
     205                                if(pos != NULL)
     206                                {
     207                                        r4 = string_resub(",'", "'", pos, 0);
     208                                        ret = getfilekey(r1, r2, r3, r4);
     209                                }
     210                        }
     211                }
     212        }
     213        else
     214        {
     215                ret = string_resub("ll=\"", "\"", cc, 0);
     216                if(ret == NULL)
     217                        ret = string_resub("filekey=\"", "\"", cc, 0); 
     218        }
     219
     220  free(r1); r1 = NULL;
     221        free(r2); r2 = NULL;
     222        free(r3); r3 = NULL;
     223        free(r4); r4 = NULL;
     224                                       
     225        return ret;
     226}
     227
    6228char* hoster(char* url)
    7229{
    8230        debug(99, "url: %s", url);
    9231        char* streamurl = NULL, *tmplink = NULL;
     232
     233/*
     234                if re.match(".*?http://www.putlocker.com/(file|embed)/", link, re.S):
     235                elif re.match(".*?http://www.sockshare.com/(file|embed)/", link, re.S):
     236                elif re.match(".*?http://www.videoslasher.com/embed/", link, re.S):
     237                elif re.match('.*?http://faststream.in', link, re.S):
     238                elif re.match('.*?http:/.*?flashx.tv', link, re.S):
     239                elif re.match('.*?http://streamcloud.eu', link, re.S):
     240                elif re.match('.*?http://vidstream.in', link, re.S):
     241                elif re.match('.*?http://xvidstage.com', link, re.S):
     242                elif re.match('.*?http://embed.nowvideo.eu', link, re.S):
     243                elif re.match('.*?.movshare.net', link, re.S):
     244                elif re.match('.*?(embed.divxstage.eu|divxstage.eu/video)', link, re.S):
     245                elif re.match('.*?videoweed.es', link, re.S):
     246                elif re.match('.*?novamov.com', link, re.S):
     247                elif re.match('.*primeshare', link, re.S):
     248                elif re.match('.*?videomega.tv', link, re.S):
     249                elif re.match('.*?bitshare.com', link, re.S):
     250                elif re.match('.*?http://movreel.com/', link, re.S):
     251                elif re.match('.*?uploadc.com', link, re.S):
     252                elif re.match('.*?http://filenuke.com', link, re.S):
     253                elif re.match('.*?http://www.youtube.com/watch', link, re.S):
     254                elif re.match('.*?http://www.mightyupload.com/embed', link, re.S):
     255                elif re.match('.*?180upload', link, re.S):
     256                elif re.match('.*?ecostream.tv', link, re.S):
     257
     258        tmplink = ostrcat(url, NULL, 0, 0);
     259
     260        if(ostrstr(tmpstr, "/Out/?s=") != NULL)
     261        {
     262                tmplink = string_replace("/Out/?s=", "", tmplink, 1);
     263                debug(99, "remove out string: %s", tmplink);
     264        }
     265
     266
     267                                                if(ostrcmp(tmphname, "Sockshare") == 0)
     268                                                        hname = ostrcat("Sockshare.com", NULL, 0, 0);
     269                                                else if(ostrcmp(tmphname, "Putlocker") == 0)
     270                                                        hname = ostrcat("Putlocker.com", NULL, 0, 0);
     271                                                else if(ostrcmp(tmphname, "Filenuke") == 0)
     272                                                        hname = ostrcat("FileNuke.com", NULL, 0, 0);
     273                                                else if(ostrcmp(tmphname, "Streamclou") == 0)
     274                                                        hname = ostrcat("StreamCloud.eu", NULL, 0, 0);
     275                                                else if(ostrcmp(tmphname, "Streamcloud") == 0)
     276                                                        hname = ostrcat("StreamCloud.eu", NULL, 0, 0);
     277                                                else if(ostrcmp(tmphname, "VidStream") == 0)
     278                                                        hname = ostrcat("VidStream.in", NULL, 0, 0);
     279                                                else if(ostrcmp(tmphname, "Flashx") == 0)
     280                                                        hname = ostrcat("FlashX.tv", NULL, 0, 0);
     281                                                else if(ostrcmp(tmphname, "PrimeShare") == 0)
     282                                                        hname = ostrcat("PrimeShare.tv", NULL, 0, 0);
     283                                                else if(ostrcmp(tmphname, "Xvidstage") == 0)
     284                                                        hname = ostrcat("XvidStage.com", NULL, 0, 0);
     285                                                else if(ostrcmp(tmphname, "Nowvideo") == 0)
     286                                                        hname = ostrcat("NowVideo.eu", NULL, 0, 0);
     287                                                else if(ostrcmp(tmphname, "Movshare") == 0)
     288                                                        hname = ostrcat("MovShare.net", NULL, 0, 0);
     289                                                else if(ostrcmp(tmphname, "MovReel") == 0)
     290                                                        hname = ostrcat("MovReel.com", NULL, 0, 0);
     291                                                else if(ostrcmp(tmphname, "NovaMov") == 0)
     292                                                        hname = ostrcat("NovaMov", NULL, 0, 0);
     293                                                else if(ostrcmp(tmphname, "DivXStage") == 0)
     294                                                        hname = ostrcat("DivXStage", NULL, 0, 0);
     295                                                else if(ostrcmp(tmphname, "PrimeShare") == 0)
     296                                                        hname = ostrcat("PrimeShare.tv", NULL, 0, 0);
     297                                                else
     298                                                {
     299                                                        hname = ostrcat(tmphname, " (coming soon)", 0, 0);
     300                                                        type = 66;
     301                                                }                                                                                               
     302*/
    10303
    11304        tmplink = ostrcat(url, NULL, 0, 0);
     
    50343        else if(ostrstr(tmplink, "thefile") != NULL)
    51344                streamurl = thefile(url);
    52         else if(ostrstr(tmplink, "youtu") != NULL)
     345        else if(ostrstr(tmplink, "youtube") != NULL)
    53346                streamurl = youtube(url);
    54347        else if(ostrstr(tmplink, "myvideo") != NULL)
     
    56349        else if(ostrstr(tmplink, "promptfile") != NULL)
    57350                streamurl = promptfile(url);
    58         else if(ostrstr(tmplink, "letwatch") != NULL || ostrstr(tmplink, "realvid") != NULL)
     351        else if(ostrstr(tmplink, "letwatch") != NULL)
    59352                streamurl = letwatch(url);
    60353        else if(ostrstr(tmplink, "vidbull") != NULL)
     
    66359        else if(ostrstr(tmplink, "amazon") != NULL)
    67360                streamurl = amazon(url);
    68         else if(ostrstr(tmplink, "thevideo") != NULL)
    69                 streamurl = thevideo(url);
    70         else if(ostrstr(tmplink, "mightyupload") != NULL)
    71                 streamurl = mightyupload(url);
    72         else if(ostrstr(tmplink, "cloudzilla") != NULL)
    73                 streamurl = cloudzilla(url);
    74         else if(ostrstr(tmplink, "vivo") != NULL)
    75                 streamurl = vivo(url);
    76         else if(ostrstr(tmplink, "streamlive") != NULL)
    77                 streamurl = streamlive(url, 0);
    78         else if(ostrstr(tmplink, "cricfree") != NULL)
    79                 streamurl = cricfree(url, 0);
    80         else if(ostrstr(tmplink, "zerocast") != NULL)
    81                 streamurl = zerocast(url, 0);
    82         else if(ostrstr(tmplink, "usachannels") != NULL)
    83                 streamurl = usachannels(url, 0);
    84361        else
    85362                textbox(_("Message"), _("The hoster is not yet supported !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0);
     
    99376
    100377        return streamurl;
    101 }
    102 
    103 struct MemoryStruct {
    104   char *memory;
    105   size_t size;
    106 };
    107 
    108 static size_t
    109 WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
    110 {
    111   size_t realsize = size * nmemb;
    112   struct MemoryStruct *mem = (struct MemoryStruct *)userp;
    113  
    114   mem->memory = realloc(mem->memory, mem->size + realsize + 1);
    115   if(mem->memory == NULL) {
    116     /* out of memory! */
    117     printf("not enough memory (realloc returned NULL)\n");
    118     return 0;
    119   }
    120  
    121   memcpy(&(mem->memory[mem->size]), contents, realsize);
    122   mem->size += realsize;
    123   mem->memory[mem->size] = 0;
    124  
    125   return realsize;
    126 }
    127 
    128 // flag = 0 (without header in output)
    129 // flag = 1 (with header in output)
    130 char* gethttps(char* url, char* localfile, char* data, char* user, char* pass, char* referer, int flag)
    131 {
    132         debug(99, "url: %s", url);
    133 
    134         int debuglevel = getconfigint("debuglevel", NULL);
    135 
    136         char* tmpstr = NULL;
    137     FILE *fp;
    138 
    139         CURL *curl_handle;
    140         CURLcode res;
    141        
    142         struct MemoryStruct chunk;
    143        
    144         chunk.memory = malloc(1);  /* will be grown as needed by the realloc above */
    145         chunk.size = 0;    /* no data at this point */
    146        
    147         curl_global_init(CURL_GLOBAL_ALL);
    148 
    149         /* init the curl session */
    150         curl_handle = curl_easy_init();
    151         if(curl_handle)
    152         {
    153             if(localfile != NULL)
    154                     fp = fopen(localfile,"wb");
    155                
    156                 /* specify URL to get */
    157                 curl_easy_setopt(curl_handle, CURLOPT_URL, url);
    158 
    159                 if(user != NULL && pass != NULL)
    160                 {
    161                         curl_easy_setopt(curl_handle, CURLOPT_USERNAME, user);
    162                         curl_easy_setopt(curl_handle, CURLOPT_PASSWORD, pass);
    163                         curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    164                 }
    165                 if(data == NULL)
    166                         curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1L);
    167                 else
    168                         curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, data);
    169                 if(flag == 1)
    170                         curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1L);
    171                 curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 5);
    172                 curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 20);
    173                 /* send all data to this function  */
    174             if(localfile == NULL)
    175                         curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
    176                 else
    177                         curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, NULL);
    178 
    179                 /* we pass our 'chunk' struct to the callback function */
    180             if(localfile == NULL)
    181                         curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
    182                 else
    183                         curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, fp);
    184 
    185                 /* some servers don't like requests that are made without a user-agent field, so we provide one */
    186                 curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
    187 //              curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko");
    188 
    189                 // This is occassionally required to stop CURL from verifying the peers certificate.
    190                 // CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if
    191                 // CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2 - check the existence of a
    192                 // common name and also verify that it matches the hostname provided)
    193 #ifdef MIPSEL
    194                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 1L);
    195 #else
    196                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
    197 #endif
    198 
    199                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L);
    200                 if(debuglevel == 99)
    201                         curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
    202                 curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, "/mnt/network/cookies");
    203                 curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, "/mnt/network/cookies");
    204                 curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
    205                 if(referer == NULL)
    206                         curl_easy_setopt(curl_handle, CURLOPT_AUTOREFERER, 1L);
    207                 else
    208                         curl_easy_setopt(curl_handle, CURLOPT_REFERER, referer);
    209 
    210                 /* get it! */
    211                 res = curl_easy_perform(curl_handle);
    212                 /* check for errors */
    213                 if(res != CURLE_OK)
    214                 {
    215                         err("failed: %s", curl_easy_strerror(res));
    216                         printf("curl error\n");
    217                 }
    218                 else
    219                 {
    220                         /*
    221                          * Now, our chunk.memory points to a memory block that is chunk.size
    222                          * bytes big and contains the remote file.
    223                          *
    224                          * Do something nice with it!
    225                          */
    226                         printf("%lu bytes retrieved\n", (long)chunk.size);
    227                 }
    228                
    229                 /* cleanup curl stuff */
    230                 curl_easy_cleanup(curl_handle);
    231                 if(localfile != NULL)
    232                         fclose(fp);
    233         }
    234 
    235         tmpstr = ostrcat(chunk.memory, NULL, 0, 0);
    236         free(chunk.memory);
    237         /* we're done with libcurl, so clean it up */
    238         curl_global_cleanup();
    239 
    240         if(localfile != NULL)
    241                 free(tmpstr), tmpstr = NULL;
    242         return tmpstr;
    243 }
    244 
    245 char* string_decode3(char* input)
    246 {
    247         if(input == NULL) return input;
    248 
    249         input = string_replace_all("&#196;", "Ä", input, 1);
    250         input = string_replace_all("&#228;", "ä", input, 1);
    251         input = string_replace_all("&#201;", "É", input, 1);
    252         input = string_replace_all("&#233;", "é", input, 1);
    253         input = string_replace_all("&#214;", "Ö", input, 1);
    254         input = string_replace_all("&#246;", "ö", input, 1);
    255         input = string_replace_all("&#220;", "Ü", input, 1);
    256         input = string_replace_all("&#252;", "ü", input, 1);
    257         input = string_replace_all("&#223;", "ß", input, 1);
    258         input = string_replace_all("&#38;", "&", input, 1);
    259 
    260         input = string_replace_all("&Auml;", "Ä", input, 1);
    261         input = string_replace_all("&auml;", "ä", input, 1);
    262         input = string_replace_all("&Eacute;", "É", input, 1);
    263         input = string_replace_all("&eacute;", "é", input, 1);
    264         input = string_replace_all("&Ouml;", "Ö", input, 1);
    265         input = string_replace_all("&ouml;", "ö", input, 1);
    266         input = string_replace_all("&Uuml;", "Ü", input, 1);
    267         input = string_replace_all("&uuml;", "ü", input, 1);
    268         input = string_replace_all("&szlig;", "ß", input, 1);
    269         input = string_replace_all("&amp;", "&", input, 1);
    270 
    271         return input;
    272 }
    273 
    274 char* getfilekey(char* w, char* i, char* s, char* e)
    275 {
    276         char* ret = NULL;
    277 
    278         if(w == NULL || i == NULL || s == NULL || e == NULL)
    279                 return NULL;
    280 
    281         int a = 0, b = 0, c = 0;
    282         int a1 = 0, b1 = 0;
    283 
    284         int lw = strlen(w);
    285         int li = strlen(i);
    286         int ls = strlen(s);
    287        
    288         if(lw < 5 || li < 5 || ls < 5)
    289                 return NULL;
    290 
    291         char ca[lw + li + ls - 14];
    292         char cb[16];
    293 
    294         ca[lw + li + ls - 15] = '\0';
    295         cb[15] = '\0';
    296        
    297         while(1)
    298         {
    299                 if(a < 5)
    300                 {
    301                         cb[b1] = w[a];
    302                         b1++;
    303                 }
    304                 else if(a < lw)
    305                 {
    306                         ca[a1] = w[a];
    307                         a1++;
    308                 }
    309                 a++;
    310                
    311                 if(b < 5)
    312                 {
    313                         cb[b1] = i[b];
    314                         b1++;
    315                 }
    316                 else if(b < li)
    317                 {
    318                         ca[a1] = i[b];
    319                         a1++;
    320                 }
    321                 b++;
    322                
    323                 if(c < 5)
    324                 {
    325                         cb[b1] = s[c];
    326                         b1++;
    327                 }
    328                 else if(c < ls)
    329                 {
    330                         ca[a1] = s[c];
    331                         a1++;
    332                 }
    333                 c++;
    334                
    335                 if(lw + li + ls == a1 + b1)
    336                         break;
    337         }
    338 
    339         b = 0;
    340         int d = 0;
    341         char cc[a1 / 2 + 1];
    342         char casub[3] = {'\0'};
    343         cc[a1 / 2] = '\0';
    344        
    345         for(a = 0; a < a1; a += 2)
    346         {
    347                 int c = -1;
    348                
    349                 if(cb[b] % 2) c = 1;
    350 
    351                 casub[0] = ca[a];
    352                 casub[1] = ca[a + 1];
    353 
    354                 cc[d] = strtol(casub, '\0', 36) - c;
    355                 b++; d++;
    356                 if(b >= b1) b = 0;
    357         }
    358 
    359         char* r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL;
    360         char* pos = ostrstr(cc, ");}('");
    361         if(pos != NULL)
    362         {
    363                 r1 = string_resub(");}('", "'", pos, 0);
    364                 pos = ostrstr(pos + 5, ",'");
    365                 if(pos != NULL)
    366                 {
    367                         r2 = string_resub(",'", "'", pos, 0);
    368                         pos = ostrstr(pos + 2, ",'");
    369                         if(pos != NULL)
    370                         {
    371                                 r3 = string_resub(",'", "'", pos, 0);
    372                                 pos = ostrstr(pos + 2, ",'");
    373                                 if(pos != NULL)
    374                                 {
    375                                         r4 = string_resub(",'", "'", pos, 0);
    376                                         ret = getfilekey(r1, r2, r3, r4);
    377                                 }
    378                         }
    379                 }
    380         }
    381         else
    382         {
    383                 ret = string_resub("ll=\"", "\"", cc, 0);
    384                 if(ret == NULL)
    385                         ret = string_resub("filekey=\"", "\"", cc, 0); 
    386         }
    387 
    388   free(r1); r1 = NULL;
    389         free(r2); r2 = NULL;
    390         free(r3); r3 = NULL;
    391         free(r4); r4 = NULL;
    392                                        
    393         return ret;
    394378}
    395379
     
    489473}
    490474
    491 char* jsunpack(char* input)
    492 {
    493         int debuglevel = getconfigint("debuglevel", NULL);
    494 
    495         if(input == NULL) return input;
    496 
    497         char* b36code = NULL, *search = NULL, *charlist = NULL, *base = NULL, *tmpstr2 = NULL, *tmpstr3 = NULL, *tmpstr = NULL, *packed = NULL;
    498 
    499         unlink("/tmp/jsunpack1_packed");
    500         unlink("/tmp/jsunpack2_tmpstr");
    501         unlink("/tmp/jsunpack3_b36code");
    502         unlink("/tmp/jsunpack4_tmpstr_last");
    503 
    504         while(ostrstr(input, "eval(function(p,a,c,k,e,d){") != NULL)
    505         {
    506                 packed = string_resub("eval(function(p,a,c,k,e,d){", "))", input, 0);
    507                 titheklog(debuglevel, "/tmp/jsunpack1_packed", NULL, NULL, NULL, packed);       
    508        
    509 //              tmpstr = string_resub(";return p}('", ");'", packed, 0);
    510 //              tmpstr = oregex(".*;return p}(.*)',[0-9]{2,2},[0-9]{2,2},'.*'.split.*", packed);
    511                 tmpstr = oregex(".*;return p}(.*)',[0-9]{1,3},[0-9]{1,3},'.*'.split.*", packed);
    512 
    513                 debug(99, "tmpstr: %s", tmpstr);
    514                 titheklog(debuglevel, "/tmp/jsunpack2_tmpstr", NULL, NULL, NULL, tmpstr);
    515        
    516 //              b36code = oregex(".*;',[0-9]{2,2},[0-9]{2,2},'(.*)'.split.*", packed);
    517                 b36code = oregex(".*',[0-9]{1,3},[0-9]{1,3},'(.*)'.split.*", packed);
    518                
    519                 b36code = string_replace_all("||", "| |", b36code, 1);
    520                 debug(99, "b36code: %s", b36code);
    521                 titheklog(debuglevel, "/tmp/jsunpack3_b36code", NULL, NULL, NULL, b36code);
    522 
    523                 if(!ostrncmp("|", b36code, 1))
    524                         b36code = ostrcat(" ", b36code, 0, 1);
    525 
    526                 struct splitstr* ret1 = NULL;
    527                 int count = 0;
    528                 int i = 0;
    529                 ret1 = strsplit(b36code, "|", &count);
    530        
    531                 charlist = ostrcat(charlist, "\"", 1, 0);
    532                 charlist = ostrcat(charlist, "|", 1, 0);
    533                 charlist = ostrcat(charlist, "'", 1, 0);
    534                 charlist = ostrcat(charlist, "|", 1, 0);
    535                 charlist = ostrcat(charlist, ".", 1, 0);
    536                 charlist = ostrcat(charlist, "|", 1, 0);
    537                 charlist = ostrcat(charlist, ";", 1, 0);
    538                 charlist = ostrcat(charlist, "|", 1, 0);
    539                 charlist = ostrcat(charlist, ":", 1, 0);
    540                 charlist = ostrcat(charlist, "|", 1, 0);
    541                 charlist = ostrcat(charlist, "=", 1, 0);
    542                 charlist = ostrcat(charlist, "|", 1, 0);
    543                 charlist = ostrcat(charlist, ",", 1, 0);
    544                 charlist = ostrcat(charlist, "|", 1, 0);
    545                 charlist = ostrcat(charlist, " ", 1, 0);
    546                 charlist = ostrcat(charlist, "|", 1, 0);
    547                 charlist = ostrcat(charlist, "\\", 1, 0);
    548                 charlist = ostrcat(charlist, "|", 1, 0);
    549                 charlist = ostrcat(charlist, "/", 1, 0);
    550                 charlist = ostrcat(charlist, "|", 1, 0);
    551                 charlist = ostrcat(charlist, "(", 1, 0);
    552                 charlist = ostrcat(charlist, "|", 1, 0);
    553                 charlist = ostrcat(charlist, ")", 1, 0);
    554                 charlist = ostrcat(charlist, "'", 1, 0);
    555                 charlist = ostrcat(charlist, "%", 1, 0);
    556        
    557                 for(i = 0; i < count; i++)
    558                 {
    559                         if(ostrstr((&ret1[i])->part, " ") != NULL)
    560                         {
    561                                 printf("continue\n");
    562                                 continue;
    563                         }
    564                         char* x = oltostr(i, 36);
    565        
    566                         struct splitstr* ret2 = NULL;
    567                         int count2 = 0;
    568                         int i2 = 0;
    569                         tmpstr2 = ostrcat(charlist, NULL, 0, 0);
    570                         ret2 = strsplit(tmpstr2, "|", &count2);
    571                         for(i2 = 0; i2 < count2; i2++)
    572                         {
    573                                 struct splitstr* ret3 = NULL;
    574                                 int count3 = 0;
    575                                 int i3 = 0;
    576                                 tmpstr3 = ostrcat(charlist, NULL, 0, 0);
    577                                 ret3 = strsplit(tmpstr3, "|", &count3);
    578                                 for(i3 = 0; i3 < count3; i3++)
    579                                 {
    580                                         debug(99, "-----------------------------------------------");
    581                                         debug(99, "replace %s%s%s <> %s%s%s",(&ret2[i2])->part, x, (&ret3[i3])->part, (&ret2[i2])->part, (&ret1[i])->part, (&ret3[i3])->part);
    582        
    583                                         base = ostrcat(base, (&ret2[i2])->part, 1, 0);
    584                                         base = ostrcat(base, x, 1, 0);
    585                                         base = ostrcat(base, (&ret3[i3])->part, 1, 0);         
    586                                         search = ostrcat(search, (&ret2[i2])->part, 1, 0);
    587                                         search = ostrcat(search, (&ret1[i])->part, 1, 0);
    588                                         search = ostrcat(search, (&ret3[i3])->part, 1, 0);
    589                                         tmpstr = string_replace_all(base, search, tmpstr, 1);
    590                                         free(base), base = NULL;
    591                                         free(search), search = NULL;
    592                                 }
    593                                 free(ret3), ret3 = NULL;
    594                                 free(tmpstr3), tmpstr3 = NULL;
    595                         }
    596                         free(ret2), ret2 = NULL;
    597                         free(tmpstr2), tmpstr2 = NULL;
    598                         free(x);
    599                 }
    600                 free(ret1), ret1 = NULL;
    601        
    602                 titheklog(debuglevel, "/tmp/jsunpack4_tmpstr_last", NULL, NULL, NULL, tmpstr);
    603 
    604                 if(tmpstr == NULL)
    605                         input = string_replace("eval(function(p,a,c,k,e,d){", "eval(function(p,a,c,k,e,d-extracted-error){", input, 1);
    606                 else
    607                 {
    608                         input = string_replace("eval(function(p,a,c,k,e,d){", "eval(function(p,a,c,k,e,d-extracted){", input, 1);
    609                         input = string_replace(packed, tmpstr, input, 1);
    610                 }
    611                 free(tmpstr),tmpstr = NULL;
    612                 free(packed), packed = NULL;
    613                 free(b36code), b36code = NULL;
    614                 free(charlist), charlist = NULL;
    615         }
    616 
    617         return input;
    618 }
    619 
    620475#endif
  • titan/plugins/tithek/tvtoast.h

    r36097 r36117  
    22#define TVTOAST_H
    33
    4 char* streamlive(char* link, int incount)
     4char* getrtmp(char* input, char* tmphost, char* tmppath, char **typemsg, char* fid, int incount)
    55{
    6         debug(99, "streamlive(%d) link=%s", incount, link);
    7 
    86        int debuglevel = getconfigint("debuglevel", NULL);
    9         char* streamurl = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
     7        char* tmpstr = ostrcat(input, NULL, 0, 0);
     8        char* tmpstr1 = NULL;
     9        char* tmpstr2 = NULL;
     10        char* tmpstr3 = NULL;
    1011        char* streamer = NULL;
    11         char* playpath = NULL;
    12         char* swfurl = NULL;
    13         char* app = NULL;
    14         char* token = NULL;
    15         char* tmpurl = NULL;
    16         char* host = NULL;
    17         char* path = NULL;
    18 
    19         tmpstr = gethttps(link, NULL, NULL, NULL, NULL, NULL, 1);
    20         free(host), host = NULL;
    21         free(path), path = NULL;
    22         host = string_resub("http://", "/", link, 0);
    23         path = string_replace_all(host, "", link, 0);
    24         path = string_replace_all("http://", "", path, 1);
    25         path = string_replace_all(" ", "%20", path, 1);
    26         titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast4_tmpstr", oitoa(incount), host, path, tmpstr);
    27 
    28         tmpurl = string_resub("src='", "'", tmpstr, 0);
    29         free(tmpstr), tmpstr = NULL;                                           
    30        
    31         tmpstr = gethttps(tmpurl, NULL, NULL, NULL, NULL, NULL, 1);
    32         free(host), host = NULL;
    33         free(path), path = NULL;
    34         host = string_resub("http://", "/", tmpurl, 0);
    35         path = string_replace_all(host, "", tmpurl, 0);
    36         path = string_replace_all("http://", "", path, 1);
    37         path = string_replace_all(" ", "%20", path, 1);
    38         titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast5_tmpstr", oitoa(incount), host, path, tmpstr);
    39        
    40         streamer = string_resub("streamer: \"", "\"", tmpstr, 0);
    41         streamer = string_replace_all("\\", "", streamer, 1);
    42         debug(99, "tvtoast5_tmpstr%d streamer=%s", incount, streamer)
    43 
    44         playpath = string_resub("file: \"", "\"", tmpstr, 0);
    45         playpath = string_replace_all(".flv", "", playpath, 1);
    46         debug(99, "tvtoast5_tmpstr%d playpath=%s", incount, playpath)
    47 
    48         swfurl = string_resub("type: 'flash', src: '", "'", tmpstr, 0);
    49         swfurl = string_replace_all("//", "http://", swfurl, 1);
    50         debug(99, "tvtoast5_tmpstr%d swfurl=%s", incount, swfurl)
    51 
    52         app = ostrcat(streamer, NULL, 0, 0);
    53         tmpstr1 = string_resub("rtmp://", "/", app, 0);
    54         app = string_replace(tmpstr1, "", app, 0);
    55         free(tmpstr1), tmpstr1 = NULL;
    56         app = string_replace_all("rtmp:///", "", app, 1);
    57         debug(99, "tvtoast5_tmpstr%d app5=%s", incount, app)
    58 
    59         tmpurl = string_resub("getJSON(\"", "\"", tmpstr, 0);
    60         tmpurl = string_replace_all("//", "http://", tmpurl, 1);
     12        //char* fid = NULL;
     13        char* swfUrl = NULL;
     14        char* cmd = NULL;
     15        char* streamurl = NULL;
     16        char* streamip = NULL;
     17
     18        ///////////////
     19        char* post = NULL;
     20        char* b36code = NULL;
     21        char* charlist = NULL;
     22        char* base = NULL;
     23        char* search = NULL;
     24        printf("neu................\n");
     25        post = ostrcat(tmpstr, NULL, 0, 0);
     26        free(tmpstr1),tmpstr1 = NULL;
     27        tmpstr1 = string_resub(";return p}('", ";',", post, 0);
     28        debug(99, "tmpstr1: %s", tmpstr1);
     29        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr_rtmp1", oitoa(incount), tmphost, tmppath, tmpstr);
     30
     31        post = string_replace_all(tmpstr1, "", post, 1);
     32        post = string_replace_all(";return p}(';',", "", post, 1);
     33        debug(99, "post1: %s", post);
     34        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr_rtmp2", oitoa(incount), tmphost, tmppath, tmpstr);
     35       
     36        free(tmpstr1),tmpstr1 = NULL;
     37        free(b36code),b36code = NULL;
     38        tmpstr1 = string_resub(";return p}('", ");'", post, 0);
     39        debug(99, "tmpstr2: %s", tmpstr1);
     40        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr_rtmp3", oitoa(incount), tmphost, tmppath, tmpstr);
     41       
     42        if(tmpstr1 != NULL)
     43        {
     44                b36code = oregex(".*;',[0-9]{1,1},[0-9]{1,1},'(.*)'.split.*", post);
     45               
     46                b36code = string_replace_all("||", "| |", b36code, 1);
     47                debug(99, "b36code: %s", b36code);
     48       
     49                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr_rtmp4", oitoa(incount), tmphost, tmppath, tmpstr);
     50                       
     51                struct splitstr* ret1 = NULL;
     52                int count = 0;
     53                int i = 0;
     54                ret1 = strsplit(b36code, "|", &count);
     55       
     56                charlist = ostrcat(charlist, "\"", 1, 0);
     57                charlist = ostrcat(charlist, "|", 1, 0);
     58                charlist = ostrcat(charlist, "'", 1, 0);
     59                charlist = ostrcat(charlist, "|", 1, 0);
     60                charlist = ostrcat(charlist, ".", 1, 0);
     61                charlist = ostrcat(charlist, "|", 1, 0);
     62                charlist = ostrcat(charlist, ";", 1, 0);
     63                charlist = ostrcat(charlist, "|", 1, 0);
     64                charlist = ostrcat(charlist, ":", 1, 0);
     65                charlist = ostrcat(charlist, "|", 1, 0);
     66                charlist = ostrcat(charlist, "=", 1, 0);
     67                charlist = ostrcat(charlist, "|", 1, 0);
     68                charlist = ostrcat(charlist, ",", 1, 0);
     69                charlist = ostrcat(charlist, "|", 1, 0);
     70                charlist = ostrcat(charlist, " ", 1, 0);
     71                charlist = ostrcat(charlist, "|", 1, 0);
     72                charlist = ostrcat(charlist, "\\", 1, 0);
     73                charlist = ostrcat(charlist, "|", 1, 0);
     74                charlist = ostrcat(charlist, "/", 1, 0);
     75                charlist = ostrcat(charlist, "|", 1, 0);
     76                charlist = ostrcat(charlist, "(", 1, 0);
     77                charlist = ostrcat(charlist, "|", 1, 0);
     78                charlist = ostrcat(charlist, ")", 1, 0);
     79       
     80                for(i = 0; i < count; i++)
     81                {
     82                        if(ostrstr((&ret1[i])->part, " ") != NULL)
     83                        {
     84                                printf("continue\n");
     85                                continue;
     86                        }
     87                        char* x = oltostr(i, 36);
     88       
     89                        struct splitstr* ret2 = NULL;
     90                        int count2 = 0;
     91                        int i2 = 0;
     92                        tmpstr2 = ostrcat(charlist, NULL, 0, 0);
     93                        ret2 = strsplit(tmpstr2, "|", &count2);
     94                        for(i2 = 0; i2 < count2; i2++)
     95                        {
     96                                struct splitstr* ret3 = NULL;
     97                                int count3 = 0;
     98                                int i3 = 0;
     99                                tmpstr3 = ostrcat(charlist, NULL, 0, 0);
     100                                ret3 = strsplit(tmpstr3, "|", &count3);
     101                                for(i3 = 0; i3 < count3; i3++)
     102                                {
     103                                        debug(99, "-----------------------------------------------");
     104                                        debug(99, "replace %s%s%s <> %s%s%s",(&ret2[i2])->part, x, (&ret3[i3])->part, (&ret2[i2])->part, (&ret1[i])->part, (&ret3[i3])->part);
     105       
     106                                        base = ostrcat(base, (&ret2[i2])->part, 1, 0);
     107                                        base = ostrcat(base, x, 1, 0);
     108                                        base = ostrcat(base, (&ret3[i3])->part, 1, 0);         
     109                                        search = ostrcat(search, (&ret2[i2])->part, 1, 0);
     110                                        search = ostrcat(search, (&ret1[i])->part, 1, 0);
     111                                        search = ostrcat(search, (&ret3[i3])->part, 1, 0);
     112                                        tmpstr1 = string_replace_all(base, search, tmpstr1, 1);
     113                                        free(base), base = NULL;
     114                                        free(search), search = NULL;
     115                                }
     116                                free(ret3), ret3 = NULL;
     117                                free(tmpstr3), tmpstr3 = NULL;
     118                        }
     119                        free(ret2), ret2 = NULL;
     120                        free(tmpstr2), tmpstr2 = NULL;
     121                        free(x);
     122                }
     123                free(ret1), ret1 = NULL;
     124                free(b36code), b36code = NULL;
     125                free(post), post = NULL;
     126                free(charlist), charlist = NULL;
     127       
     128                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr_rtmp5", oitoa(incount), tmphost, tmppath, tmpstr);
     129
     130///////////////
     131        }
     132       
     133        streamer = string_resub("'streamer':           '", "',", tmpstr, 0);
     134        if(streamer != NULL)
     135        {
     136                fid = string_resub("'file':               '", "',", tmpstr, 0);
     137                swfUrl = string_resub("swfobject.embedSWF('", "',", tmpstr, 0);
     138        }
     139        else
     140        {
     141                streamer = string_resub("var str = \"", "\"", tmpstr, 0);
     142                if(streamer != NULL)
     143                {
     144                        if(ostrstr(tmpstr1, "str.replace(") != NULL)
     145                        {
     146                                char* org = string_resub("str.replace(\"", "\"", tmpstr1, 0);
     147                                char* replace = string_resub("\",\"", "\"", tmpstr1, 0);
     148                                printf("org streamer: %s\n",streamer);
     149                                streamer = string_replace_all(org, replace, streamer, 1);
     150                                free(org), org = NULL;
     151                                free(replace), replace = NULL;
     152
     153                                printf("change streamer: %s\n",streamer);
     154                        }
     155                        free(tmpstr1), tmpstr1 = NULL;
     156                        swfUrl = string_resub("SWFObject(\"", "\"", tmpstr, 0);
     157                }
     158        }
     159
     160        if(streamer == NULL)
     161                streamer = string_resub("file: \"", "\"", tmpstr, 0);
     162
     163        if(streamer == NULL)
     164                streamer = string_resub("'file': '", "'", tmpstr, 0);
     165
     166        cmd = ostrcat("rtmpdump -r ", NULL, 0, 0);
     167        cmd = ostrcat(cmd, streamer, 1, 0);
     168        if(fid != NULL)
     169        {
     170                cmd = ostrcat(cmd, "/", 1, 0);
     171                cmd = ostrcat(cmd, fid, 1, 0);
     172        }
     173        else
     174                fid = basename(streamer);
     175
     176        cmd = ostrcat(cmd, " --debug > /tmp/tithek/rtmp.log 2>&1", 1, 0);                                                                                               
     177        system("rm -rf /tmp/tithek/rtmp.log");
     178
    61179        free(tmpstr), tmpstr = NULL;
    62 
    63         tmpstr = gethttps(tmpurl, NULL, NULL, NULL, NULL, NULL, 1);
    64         free(host), host = NULL;
    65         free(path), path = NULL;
    66         host = string_resub("http://", "/", tmpurl, 0);
    67         path = string_replace_all(host, "", tmpurl, 0);
    68         path = string_replace_all("http://", "", path, 1);
    69         path = string_replace_all(" ", "%20", path, 1);
    70         titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast6_tmpstr", oitoa(incount), host, path, tmpstr);
    71 
    72         token = string_resub("{\"token\":\"", "\"", tmpstr, 0);
    73 
    74         streamurl = ostrcat(streamer, " app=", 0, 0);
    75         streamurl = ostrcat(streamurl, app, 1, 0);
     180        printf("cmd: %s\n",cmd);
     181        system(cmd);
     182        free(cmd),cmd = NULL;
     183
     184        tmpstr = command("cat /tmp/tithek/rtmp.log");
     185
     186        streamip = string_resub("redirect, STRING:", ">", tmpstr, 0);
     187        strstrip(streamip);
     188
     189        free(tmpstr), tmpstr = NULL;
     190
     191        if(streamip == NULL)
     192        {
     193                streamip = ostrcat(streamip, streamer, 1, 0);
     194//                                              streamip = ostrcat(streamip, "/", 1, 0);
     195//                                              streamip = ostrcat(streamip, fid, 1, 0);
     196        }
     197       
     198        if(streamip == NULL) return NULL;
     199       
     200        streamurl = ostrcat(streamip, NULL, 0, 0);
    76201        streamurl = ostrcat(streamurl, " playpath=", 1, 0);
    77         streamurl = ostrcat(streamurl, playpath, 1, 0);
    78         streamurl = ostrcat(streamurl, " swfUrl=", 1, 0);
    79         streamurl = ostrcat(streamurl, swfurl, 1, 0);
    80         streamurl = ostrcat(streamurl, " live=1", 1, 0);
    81         streamurl = ostrcat(streamurl, " timeout=15", 1, 0);
    82         streamurl = ostrcat(streamurl, " token=", 1, 0);
    83         streamurl = ostrcat(streamurl, token, 1, 0);
    84         streamurl = ostrcat(streamurl, " pageUrl=", 1, 0);
    85         streamurl = ostrcat(streamurl, tmpurl, 1, 0);
    86 
    87 /*
    88         rtmp://163.172.8.19:1935/edge/_definst_/?xs=_we_Mzcxamx1aXJsamNzamVufDE0NDY5MDkxODF8OTUuOTEuNi4yNXw1NjNjYzM3ZGIxNTU1fGQzOTYwODlmYjQyOGViYjRhZGQ0YjU3NDgwODY1Zjk2Nzk5ZTE4OWU. app=edge/_definst_/?xs=_we_Mzcxamx1aXJsamNzamVufDE0NDY5MDkxODF8OTUuOTEuNi4yNXw1NjNjYzM3ZGIxNTU1fGQzOTYwODlmYjQyOGViYjRhZGQ0YjU3NDgwODY1Zjk2Nzk5ZTE4OWU. playpath=371jluirljcsjen swfUrl=http://www.streamlive.to/ads/embed/player_ilive_embed.swf live=1 timeout=15 token=Qb582083d22804a892ce37092f7f3d2d pageUrl=http://www.streamlive.to/server.php?id=1446822781
    89 */
    90 
    91         free(streamer), streamer = NULL;
    92         free(app), app = NULL;
    93         free(playpath), playpath = NULL;
    94         free(swfurl), swfurl = NULL;
    95         free(token), token = NULL;
    96         free(host), host = NULL;
    97         free(path), path = NULL;
    98 
    99         debug(99, "streamurl %s", streamurl);
    100         return streamurl;
    101 }
    102 
    103 char* zerocast(char* link, int incount)
    104 {
    105         debug(99, "zerocast(%d) link=%s ", incount, link);
    106         char* streamurl = NULL;
    107         char* host = NULL;
    108 
    109         host = string_resub("http://", "/", link, 0);
    110         free(host), host = NULL;
    111 
    112         debug(99, "streamurl %s", streamurl);
    113         return streamurl;
    114 }
    115 
    116 char* usachannels(char* link, int incount)
    117 {
    118         debug(99, "usachannels(%d) link=%s", incount, link);
    119         char* streamurl = NULL;
    120         char* host = NULL;
    121 
    122         host = string_resub("http://", "/", link, 0);
    123         free(host), host = NULL;
    124 
    125         debug(99, "streamurl %s", streamurl);
    126         return streamurl;
    127 }
    128 
    129 char* cricfree(char* link, int incount)
    130 {
    131         debug(99, "cricfree(%d) link=%s", incount, link);
    132         int debuglevel = getconfigint("debuglevel", NULL);
    133 
    134         char* url = NULL;
    135         char* token = NULL;
    136         char* streamurl = NULL;
    137         char* tmpstr = NULL;
    138         char* fid = NULL;
    139         char* width = NULL;
    140         char* height = NULL;
    141         char* pageurl = NULL;
    142         char* swfurl = NULL;
    143         char* host = NULL;
    144         char* path = NULL;
    145 
    146         tmpstr = gethttps(link, NULL, NULL, NULL, NULL, NULL, 1);
    147         host = string_resub("http://", "/", link, 0);
    148         path = string_replace_all(host, "", link, 0);
    149         path = string_replace_all("http://", "", path, 1);
    150         path = string_replace_all(" ", "%20", path, 1);
    151         titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast4_tmpstr", oitoa(incount), host, path, tmpstr);
    152 
    153 //<script type='text/javascript'>id='espnuk'; width='620'; height='490';</script><script type='text/javascript' src='http://theactionlive.com/livegamecr.js'></script>
    154 //document.write('<iframe width="'+width+'" height="'+height+'" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" allowtransparency="true" src="http://theactionlive.com/livegamecr2.php?id='+id+'&width='+width+'&height='+height+'&stretching='+stretching+'"></iframe>');
    155 
    156         fid = string_resub("id='", "'", tmpstr, 0);
    157         width = string_resub("v_width=", ";", tmpstr, 0);
    158         height = string_resub("v_height=", ";", tmpstr, 0);
    159         url = string_resub("src='", "'", tmpstr, 0);
    160 
    161         if(width == NULL)
    162                 width = string_resub("width='", "'", tmpstr, 0);
    163         if(height == NULL)
    164                 height = string_resub("height='", "'", tmpstr, 0);
    165 
    166         if(width == NULL)
    167                 width = string_resub("var width = '", "'", tmpstr, 0);
    168         if(height == NULL)
    169                 height = string_resub("var height = '", "'", tmpstr, 0);
    170 
    171         debug(99, "fid=%s width=%s height=%s", fid, width, height);
    172 
    173         tmpstr = gethttps(url, NULL, NULL, NULL, NULL, link, 1);
    174         free(host), host = NULL;
    175         free(path), path = NULL;
    176         host = string_resub("http://", "/", url, 0);
    177         path = string_replace_all(host, "", url, 0);
    178         path = string_replace_all("http://", "", path, 1);
    179         path = string_replace_all(" ", "%20", path, 1);
    180         titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast5_tmpstr", oitoa(incount), host, path, tmpstr);
    181 
    182         pageurl = string_resub("src=\"", "\"", tmpstr, 0);
    183         pageurl = string_replace_all(" ", "", pageurl, 1);
    184         pageurl = string_replace_all("+v_", "+", pageurl, 1);
    185         pageurl = string_replace("'+fid+'", "'+id+'", pageurl, 1);
    186         pageurl = string_replace("'+id+'", fid, pageurl, 1);
    187         pageurl = string_replace("'+width+'", width, pageurl, 1);
    188         pageurl = string_replace("'+height+'", height, pageurl, 1);
    189         pageurl = string_replace("'+stretching+'", "", pageurl, 1);
    190 
    191         tmpstr = gethttps(pageurl, NULL, NULL, NULL, NULL, link, 1);
    192         free(host), host = NULL;
    193         free(path), path = NULL;
    194         host = string_resub("http://", "/", pageurl, 0);
    195         path = string_replace_all(host, "", pageurl, 0);
    196         path = string_replace_all("http://", "", path, 1);
    197         path = string_replace_all(" ", "%20", path, 1);
    198         titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast6_tmpstr", oitoa(incount), host, path, tmpstr);
    199 
    200         url = string_resub("file: \"", "\"", tmpstr, 0);
    201 
    202         if(url == NULL)
    203         {
    204 //              biggestplayer.me
    205 //              url: http://biggestplayer.me/playercr.js, file=tithek_global.h, func=gethttps, line=124
    206 
    207                 fid = string_resub("id='", "'", tmpstr, 0);
    208                 url = string_resub("src='", "'", tmpstr, 0);
    209 
    210                 debug(99, "fid=%s url=%s", fid, url);
    211 
    212                 url = string_replace_all(" ", "", url, 1);
    213                 url = string_replace_all("+v_", "+", url, 1);
    214                 url = string_replace_all("'+", "+", url, 1);
    215                 url = string_replace_all("+'", "+", url, 1);
    216                 url = string_replace("+fid+", "+id+", url, 1);
    217                 url = string_replace("+id+", fid, url, 1);
    218                 url = string_replace("+width+", width, url, 1);
    219                 url = string_replace("+height+", height, url, 1);
    220                 url = string_replace("+stretching+", "", url, 1);
    221 
    222                 tmpstr = gethttps(url, NULL, NULL, NULL, NULL, link, 1);
    223                 free(host), host = NULL;
    224                 free(path), path = NULL;
    225                 host = string_resub("http://", "/", url, 0);
    226                 path = string_replace_all(host, "", url, 0);
    227                 path = string_replace_all("http://", "", path, 1);
    228                 path = string_replace_all(" ", "%20", path, 1);
    229                 titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast7_tmpstr", oitoa(incount), host, path, tmpstr);
    230 
    231 //              url: http://biggestplayer.me/streamcrnoscrape.php?id=+id+&width=&height=,
    232 
    233                 url = string_resub("src=\"", "\"", tmpstr, 0);         
    234                 url = string_replace_all(" ", "", url, 1);
    235                 url = string_replace_all("+v_", "+", url, 1);
    236                 url = string_replace_all("'+", "+", url, 1);
    237                 url = string_replace_all("+'", "+", url, 1);
    238                 url = string_replace("+fid+", "+id+", url, 1);
    239                 url = string_replace("+id+", fid, url, 1);
    240                 url = string_replace("+width+", width, url, 1);
    241                 url = string_replace("+height+", height, url, 1);
    242                 url = string_replace("+stretching+", "", url, 1);
    243 
    244                 tmpstr = gethttps(url, NULL, NULL, NULL, NULL, pageurl, 1);
    245                 free(host), host = NULL;
    246                 free(path), path = NULL;
    247                 host = string_resub("http://", "/", url, 0);
    248                 path = string_replace_all(host, "", url, 0);
    249                 path = string_replace_all("http://", "", path, 1);
    250                 path = string_replace_all(" ", "%20", path, 1);
    251                 titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast8_tmpstr", oitoa(incount), host, path, tmpstr);
    252                 streamurl = string_resub("file: \"", "\"", tmpstr, 0);
    253 /*
    254                 http://178.18.31.52:8081/liverepeater/224731/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9MTEvNi8yMDE1IDM6MDc6MDIgUE0maGFzaF92YWx1ZT1TUUJsM3JoVWNLKzIwVytTdVdRVThRPT0mdmFsaWRtaW51dGVzPTQ=
    255 */
    256         }
    257         else
    258         {
    259 
    260                 token = string_resub("securetoken: \"", "\"", tmpstr, 0);
    261                 debug(99, "token: %s", token);
    262 
    263                 streamurl = ostrcat(streamurl, url, 1, 0);
    264                 streamurl = ostrcat(streamurl, " swfUrl=http://p.jwpcdn.com/6/11/jwplayer.flash.swf", 1, 0);
    265         //      streamurl = ostrcat(streamurl, swfurl, 1, 0);
    266                 streamurl = ostrcat(streamurl, " live=1", 1, 0);
    267                 streamurl = ostrcat(streamurl, " token=", 1, 0);
    268                 streamurl = ostrcat(streamurl, token, 1, 0);
    269                 streamurl = ostrcat(streamurl, " timeout=15", 1, 0);
    270                 streamurl = ostrcat(streamurl, " swfVfy=1", 1, 0);
    271                 streamurl = ostrcat(streamurl, " pageUrl=", 1, 0);
    272                 streamurl = ostrcat(streamurl, pageurl, 1, 0);
    273 /*
    274                 rtmp://31.220.2.148/redirect/espnusa swfUrl=http://p.jwpcdn.com/6/11/jwplayer.flash.swf live=1 token=%Zrey(nKa@#Z timeout=14 swfVfy=1 pageUrl=http://yotv.co/embed.php?live=espnusa&vw=620&vh=490
    275                 rtmp://31.220.2.148/redirect/espn2 swfUrl=http://p.jwpcdn.com/6/11/jwplayer.flash.swf live=1 token=%Zrey(nKa@#Z timeout=15 swfVfy=1 pageUrl=http://www.yotv.co/embed.php?live=espn2&vw=620&vh=490
    276                 rtmp://31.220.2.148/redirect/tsnx2 swfUrl=http://p.jwpcdn.com/6/11/jwplayer.flash.swf live=1 token=%Zrey(nKa@#Z timeout=15 swfVfy=1 pageUrl=http://www.yotv.co/embed.php?live=tsnx2&vw=620&vh=490
    277 */
    278         }
    279 
    280         free(host), host = NULL;
    281         free(path), path = NULL;
    282         free(url), url = NULL;
    283         free(token), token = NULL;
    284         free(tmpstr), tmpstr = NULL;
    285         free(fid), fid = NULL;
    286         free(width), width = NULL;
    287         free(height), height = NULL;
    288         free(pageurl), pageurl = NULL;
    289         free(swfurl), swfurl = NULL;
    290        
    291         debug(99, "streamurl %s", streamurl);
     202        streamurl = ostrcat(streamurl, fid, 1, 0);
     203        if(swfUrl != NULL)
     204        {
     205                streamurl = ostrcat(streamurl, " swfUrl=", 1, 0);
     206                streamurl = ostrcat(streamurl, swfUrl, 1, 0);
     207        }
     208        streamurl = ostrcat(streamurl, " pageUrl=http://", 1, 0);
     209        streamurl = ostrcat(streamurl, tmphost, 1, 0);
     210        streamurl = ostrcat(streamurl, "/ live=true", 1, 0);
     211        streamurl = ostrcat(streamurl, " swfVfy=true", 1, 0);
     212        streamurl = ostrcat(streamurl, " timeout=60", 1, 0);
     213
     214        printf("streamurl: %s\n",streamurl);
    292215        return streamurl;
    293216}
     
    297220        debug(99, "link %s", link);
    298221        int debuglevel = getconfigint("debuglevel", NULL);
    299         char* streamurl = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
    300         char* title = NULL, *pic = NULL;
     222        char* ip = NULL, *pos = NULL, *path = NULL, *fid = NULL, *streamurl = NULL, *tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL, *channelid = NULL;
     223        char* tmppath = NULL, *streamurl1 = NULL, *tmpurl = NULL, *streamport = NULL, *streamip = NULL, *streamid = NULL, *tmphost = NULL, *title = NULL, *pic = NULL;
     224        char* streamer = NULL;
     225        char* playpath = NULL;
     226        char* swfUrl = NULL;
     227        char* app = NULL;
     228        char* url = NULL;
     229        char* Cookie1 = NULL;
     230        char* tmpstr4 = NULL;
     231        char* tmpstr5 = NULL;
     232        char* token = NULL;
    301233        char* typemsg = NULL;
    302         char* host = NULL;
    303         char* path = NULL;
    304         char* url = NULL;
    305 
    306         system("rm -rf /var/usr/local/share/titan/plugins/tithek/tvtoast*");
    307 
    308         host = string_resub("http://", "/", link, 0);
    309         path = string_replace_all(host, "", link, 0);
    310         path = string_replace_all("http://", "", path, 1);
    311         path = string_replace_all(" ", "%20", path, 1);
    312         tmpstr = gethttps(link, NULL, NULL, NULL, NULL, NULL, 1);
    313         titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast1_tmpstr", "1", host, path, tmpstr);
     234        char* referer = NULL;
     235        char* send = NULL;
     236        char* tmpstr3 = NULL;
     237        char* pageurlid = NULL;
     238        char* pageurl = NULL;
     239        char* cmd = NULL;
     240        char* urlid = NULL;
     241        char* tokenid = NULL;
     242                       
     243        ip = string_replace("http://", "", (char*)link, 0);
     244
     245        if(ip != NULL)
     246                pos = strchr(ip, '/');
     247        if(pos != NULL)
     248        {
     249                pos[0] = '\0';
     250                path = pos + 1;
     251        }
     252       
     253        system("rm -rf /var/usr/local/share/titan/plugins/tithek/tvtoast_*");
     254
     255        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
     256        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr1", "1", tmphost, tmppath, tmpstr);
     257
     258        free(tmppath), tmppath = NULL;
     259        free(tmphost), tmphost = NULL;
     260        free(tmpurl), tmpurl = NULL;
     261        free(tmpstr2), tmpstr2 = NULL;
     262
    314263
    315264        tmpstr1 = string_resub("<ul class=\"player-top-links\">", "<div class=\"float-clear\"></div>", tmpstr, 0);
    316         titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast2_tmpstr_tmpstr1_resub", "1", host, path, tmpstr1);
    317         free(host), host = NULL;
    318         free(path), path = NULL;
    319                                
    320265        free(tmpstr), tmpstr = NULL;
    321266        printf("tmpstr1: %s\n",tmpstr1);
    322267
    323         int count = 0, i = 0, incount = 0;     
     268        int count = 0, i = 0, incount = 0, www = 1;     
    324269        struct splitstr* ret1 = NULL;
    325270        struct menulist* mlist = NULL, *mbox = NULL;
     
    334279                                printf("####################### start (%d) ############################\n", incount);
    335280
    336                                 url = string_resub("<a href=\"", "\"", ret1[i].part, 0);
    337                                 url = string_replace_all(" ", "%20", url, 1);
    338                                 tmpstr = gethttps(url, NULL, NULL, NULL, NULL, NULL, 1);
    339                                 host = string_resub("http://", "/", url, 0);
    340                                 path = string_replace_all(host, "", url, 0);
    341                                 path = string_replace_all("http://", "", path, 1);
    342                                 path = string_replace_all(" ", "%20", path, 1);
    343                                 titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast3_tmpstr", oitoa(incount), host, path, tmpstr);
    344                                 free(url), url = NULL;
    345                                 url = string_resub("src=\"", "\"", tmpstr, 0);                         
    346                                 typemsg = string_resub("http://", "/", url, 0);
    347 
    348                                 if(ostrstr(url, "www.streamlive.to") != NULL)
    349                                         streamurl = streamlive(url, incount);
    350 
    351                                 if(ostrstr(url, "zerocast.tv") != NULL)
    352                                         streamurl = zerocast(url, incount);
    353 
    354                                 if(ostrstr(url, "usachannels.tv") != NULL)
    355                                         streamurl = usachannels(url, incount);
    356 
    357                                 if(ostrstr(url, "cricfree.sx") != NULL)
    358                                         streamurl = cricfree(url, incount);
    359 
    360                                 debug(99, "streamurl%d streamurl: %s", incount, streamurl);
    361 
    362 ////////////////////
    363                                 if(ostrstr(streamurl, "rtmp") != NULL)
    364                                         title = ostrcat("Rtmpe Stream (", NULL, 0, 0);
     281                                referer = string_resub("<a href=\"", "\"", ret1[i].part, 0);
     282                                tmphost = string_resub("http://", "/", ret1[i].part, 0);
     283                                tmppath = string_resub("http://tvtoast.com/", "\"", ret1[i].part, 0);
     284                                tmppath = string_replace_all(" ", "%20", tmppath, 1);
     285
     286                                tmpstr = gethttp(tmphost, tmppath, 80, NULL, NULL, 10000, NULL, 0);
     287                                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr2", oitoa(incount), tmphost, tmppath, tmpstr);
     288                                free(tmppath), tmppath = NULL;
     289                                free(tmphost), tmphost = NULL;
     290                                free(tmpurl), tmpurl = NULL;
     291
     292                                if(ostrstr(tmpstr, "channel.php?a=") != NULL)
     293                                        www = 0;
     294
     295                                tmpurl = string_resub("src=\"", "\"", tmpstr, 0);                               
     296                                tmphost = string_resub("http://", "/", tmpurl, 0);
     297                                typemsg = ostrcat(tmphost, NULL, 0, 0);
     298                                                       
     299                                tmppath = string_replace_all(tmphost, "", tmpurl, 0);
     300                                tmppath = string_replace_all("http://", "", tmppath, 1);
     301
     302                                send = ostrcat(NULL, "GET ", 0, 0);
     303                                send = ostrcat(send, tmppath, 1, 0);
     304                                send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: gzip\r\nHost: ", 1, 0);     
     305                                send = ostrcat(send, tmphost, 1, 0);
     306                                send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nConnection: close\r\n", 1, 0);     
     307                                send = ostrcat(send, "Referer: ", 1, 0);
     308                                send = ostrcat(send, referer, 1, 0);
     309
     310                                //send = ostrcat(send, "\r\nCookie: ", 1, 0);   
     311                                //send = ostrcat(send, Cookie1, 1, 0);
     312                                send = ostrcat(send, "\r\n\r\n", 1, 0);
     313                                               
     314                                debug(99, "send: %s", send);
     315                                tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
     316                                free(send), send = NULL;
     317                                               
     318                                // fix espn
     319                                referer = ostrcat(tmpurl, NULL, 0, 0);
     320                                fid = string_resub("fid=\"", "\"", tmpstr, 0);
     321                                printf("fid111111111111: %s\n",fid);
     322
     323                                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr3", oitoa(incount), tmphost, tmppath, tmpstr);
     324                                free(tmppath), tmppath = NULL;
     325//                              free(tmphost), tmphost = NULL;
     326                                free(tmpurl), tmpurl = NULL;
     327
     328                                if(ostrstr(tmpstr, "rtmp://") != NULL || ostrstr(tmpstr, "rtmpe://") != NULL)
     329                                {
     330                                        streamurl = getrtmp(tmpstr, tmphost, tmppath, &typemsg, fid, incount);
     331                                }
     332
     333                                if(www == 1)
     334                                {
     335printf("fid44444444444444: %s\n",fid);
     336                                        if(ostrstr(tmpstr, "Moved Permanently") != NULL && ostrstr(tmphost, "www.") == NULL)
     337                                        {
     338printf("fid55555555555555: %s\n",fid);
     339                                                printf("found Moved Permanently\n");
     340                                                free(tmpstr), tmpstr = NULL;
     341                                                tmpstr = ostrcat("www.", tmphost, 0, 0);
     342                                                free(tmphost), tmphost = NULL;
     343                                                tmphost = ostrcat(tmpstr, NULL, 0, 0);
     344                                        }
     345                                        else
     346                                        {
     347printf("fid6666666666666: %s\n",fid);
     348                                                if(fid == NULL)
     349                                                        fid = string_resub("fid='", "'", tmpstr, 0);
     350                                                free(tmppath), tmppath = NULL;
     351                                                free(tmphost), tmphost = NULL;
     352                                                tmpurl = string_resub("src='", "'", tmpstr, 0);
     353                                                if(tmpurl == NULL)
     354                                                        tmpurl = string_resub("src=\"", "\"", tmpstr, 0);
     355                                                       
     356                                                free(tmpstr), tmpstr = NULL;                                           
     357                                                tmphost = string_resub("http://", "/", tmpurl, 0);             
     358                                                tmppath = string_replace_all(tmphost, "", tmpurl, 0);
     359                                                tmppath = string_replace_all("http://", "", tmppath, 1);
     360
     361                                                send = ostrcat(NULL, "GET ", 0, 0);
     362                                                send = ostrcat(send, tmppath, 1, 0);
     363                                                send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);     
     364                                                send = ostrcat(send, tmphost, 1, 0);
     365                                                send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nConnection: close\r\n", 1, 0);     
     366                                                send = ostrcat(send, "\r\nAccept-Encoding: gzip\r\n\r\n", 1, 0);       
     367                                       
     368                                                debug(99, "send: %s", send);
     369                                                tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
     370                                                free(send), send = NULL;
     371
     372                                                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr4", oitoa(incount), tmphost, tmppath, tmpstr);
     373                //                              free(tmppath), tmppath = NULL;
     374                //                              free(tmphost), tmphost = NULL;
     375                //                              free(tmpurl), tmpurl = NULL;
     376
     377                                                streamer = string_resub("streamer: \"", "\"", tmpstr, 0);
     378
     379                                                if(streamer == NULL && fid == NULL)
     380                                                {
     381                                                        printf("streamer and fid null\n");
     382                                                        tmpurl = string_resub("src='", "'", tmpstr, 0);
     383                                                        if(tmpurl == NULL || ostrncmp("http://", tmpurl, 7))
     384                                                                tmpurl = string_resub("src=\"", "\"", tmpstr, 0);
     385                                                        if(tmpurl == NULL || ostrncmp("http://", tmpurl, 7))
     386                                                                tmpurl = string_resub("var url = '", "'", tmpstr, 0);
     387
     388                                                        printf("tmpurl: %s\n", tmpurl);
     389
     390                                                        free(tmpstr), tmpstr = NULL;                                           
     391                                                        tmphost = string_resub("http://", "/", tmpurl, 0);             
     392                                                        tmppath = string_replace_all(tmphost, "", tmpurl, 0);
     393                                                        tmppath = string_replace_all("http://", "", tmppath, 1);
     394                                       
     395                                                        send = ostrcat(NULL, "GET ", 0, 0);
     396                                                        send = ostrcat(send, tmppath, 1, 0);
     397                                                        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);     
     398                                                        send = ostrcat(send, tmphost, 1, 0);
     399                                                        send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nConnection: close\r\n", 1, 0);     
     400                                                        send = ostrcat(send, "\r\nAccept-Encoding: gzip\r\n\r\n", 1, 0);       
     401
     402                                printf("send3c1: %s\n", send);
     403
     404                                                        debug(99, "send: %s", send);
     405                                                        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
     406                                                        free(send), send = NULL;
     407
     408                                                        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr5", oitoa(incount), tmphost, tmppath, tmpstr);
     409                        //                              free(tmppath), tmppath = NULL;
     410                        //                              free(tmphost), tmphost = NULL;
     411                                                        free(tmpurl), tmpurl = NULL;
     412
     413/////////////////////////
     414
     415                                                        swfUrl = string_resub("<script type=\"text/javascript\" src=\"", "\"", tmpstr, 0);
     416                                                        fid = string_resub("'file':               '", "',", tmpstr, 0);
     417
     418                                                        if(ostrstr(tmpstr, "rtmp://") != NULL)
     419                                                        {
     420                                                                streamurl = getrtmp(tmpstr, tmphost, tmppath, &typemsg, fid, incount);
     421                                                                //rtmp://37.220.32.52:443/liverepeater playpath=stream3 swfUrl=http://static.surk.tv/player.swf pageUrl=http://1cdn.filotv.pw/stream3.html token=#atd%#$ZH
     422                                                        }
     423                                                }
     424                                               
     425                                                if(streamurl == NULL)
     426                                                {
     427printf("fid888888888888: %s\n",fid);
     428                                                        streamer = string_replace_all("\\", "", streamer, 1);
     429                                               
     430                                                        playpath = string_resub("file: \"", "\"", tmpstr, 0);
     431                                                        playpath = string_replace_all(".flv", "", playpath, 1);
     432                                               
     433                                                        swfUrl = string_resub("type: 'flash', src: '", "'", tmpstr, 0);
     434                                        //              pageUrl = ostrcat("http://www.ilive.to", NULL, 0, 0);
     435                                                        printf("streamer: %s\n", streamer);
     436                                                        app = string_resub("/edge/", "\0", streamer, 0);
     437                                                       
     438                                                        app = oregex(".*(/edge/) .*", streamer);
     439                                               
     440                                                        app = ostrcat(streamer, NULL, 0, 0);
     441                                                        url = string_resub("rtmp://", "/", app, 0);             
     442                                                        app = string_replace(url, "", app, 0);
     443                                                        app = string_replace_all("rtmp:///", "", app, 1);
     444                                                }
     445
     446                                                while(ostrstr(tmpstr, "Set-Cookie:") != NULL)
     447                                                {
     448                                                        tmpstr4 = string_resub("Set-Cookie:", ";", tmpstr, 0);
     449                                                       
     450                                                        if(tmpstr4 != NULL)
     451                                                        {
     452                                                                tmpstr5 = ostrcat("Set-Cookie: ", tmpstr4, 0, 0);
     453                                                                tmpstr5 = ostrcat(tmpstr5, ";", 1, 0);
     454                                                                tmpstr = string_replace(tmpstr5, "", tmpstr, 1);
     455                                                                tmpstr4 = ostrcat(tmpstr4, "; ", 1, 0);
     456                                                                Cookie1 = ostrcat(Cookie1, tmpstr4, 1, 0);
     457                                                        }
     458                                                        free(tmpstr4), tmpstr4 = NULL;
     459                                                        free(tmpstr5), tmpstr5 = NULL;
     460                                                }
     461
     462                                                if(ostrstr(tmpstr, "getJSON(\"") != NULL)
     463                                                {
     464printf("fid999999999999: %s\n",fid);
     465                                                        printf("found getJSON\n");
     466                                                        tmpurl = string_resub("getJSON(\"", "\"", tmpstr, 0);
     467                                                       
     468                                                        printf("tmpurl: %s\n", tmpurl);
     469                                                        tmphost = string_resub("http://", "/", tmpurl, 0);                     
     470                                                        tmppath = string_replace_all(tmphost, "", tmpurl, 0);
     471                                                        tmppath = string_replace_all("http://", "", tmppath, 1);
     472                                                        free(fid), fid = NULL;
     473                                                        free(tmpstr), tmpstr = NULL;
     474
     475                                                        send = ostrcat(NULL, "GET ", 0, 0);
     476                                                        send = ostrcat(send, tmppath, 1, 0);
     477                                                        send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: gzip\r\nHost: ", 1, 0);     
     478                                                        send = ostrcat(send, tmphost, 1, 0);
     479                                                        send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nConnection: close\r\n", 1, 0);     
     480                                                        send = ostrcat(send, "Referer: ", 1, 0);
     481                                                        send = ostrcat(send, "http://", 1, 0);
     482                                                        send = ostrcat(send, tmphost, 1, 0);
     483
     484                                                        send = ostrcat(send, "\r\nCookie: ", 1, 0);     
     485                                                        send = ostrcat(send, Cookie1, 1, 0);
     486                                                        send = ostrcat(send, "\r\n\r\n", 1, 0);
     487                       
     488                                                        debug(99, "send: %s", send);
     489                                                        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
     490                                                        free(send), send = NULL;
     491                                                        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr6", oitoa(incount), tmphost, tmppath, tmpstr);
     492                        //                              free(tmppath), tmppath = NULL;
     493                        //                              free(tmphost), tmphost = NULL;
     494                                                        free(tmpurl), tmpurl = NULL;
     495
     496
     497                                                        token = string_resub("{\"token\":\"", "\"", tmpstr, 0);
     498
     499                                                        streamurl1 = ostrcat(streamer, " app=", 0, 0);
     500                                                        streamurl1 = ostrcat(streamurl1, app, 1, 0);
     501                                                        streamurl1 = ostrcat(streamurl1, " playpath=", 1, 0);
     502                                                        streamurl1 = ostrcat(streamurl1, playpath, 1, 0);
     503                                                        streamurl1 = ostrcat(streamurl1, " swfUrl=", 1, 0);
     504                                                        streamurl1 = ostrcat(streamurl1, swfUrl, 1, 0);
     505                                                        streamurl1 = ostrcat(streamurl1, " live=1", 1, 0);
     506                                                        streamurl1 = ostrcat(streamurl1, " timeout=15", 1, 0);
     507                                                        streamurl1 = ostrcat(streamurl1, " token=", 1, 0);
     508                                                        streamurl1 = ostrcat(streamurl1, token, 1, 0);
     509                                                        streamurl1 = ostrcat(streamurl1, " pageUrl=http://", 1, 0);
     510                                                        streamurl1 = ostrcat(streamurl1, tmphost, 1, 0);
     511                                                        typemsg = ostrcat(tmphost, NULL, 0, 0);
     512                                                }
     513                                                else if(fid != NULL)
     514                                                {
     515                                                        printf("found fid: %s\n", fid);
     516                                                        tmpurl = string_resub("src=\"", "'", tmpstr, 0);
     517
     518                                                        tmphost = string_resub("http://", "/", tmpurl, 0);                     
     519                                                        tmppath = string_replace_all(tmphost, "", tmpurl, 0);
     520                                                        tmppath = string_replace_all("http://", "", tmppath, 1);
     521                                                        tmppath = ostrcat(tmppath, fid, 1, 0);
     522
     523                                                        //free(fid), fid = NULL;
     524                                                        free(tmpstr), tmpstr = NULL;
     525                                                }
     526                                                else
     527                                                {
     528                                                        printf("found no fid: %s\n", fid);
     529                                                        streamurl1 = string_resub("streamer: \"", "\"", tmpstr, 0);
     530                                                        if(streamurl1 != NULL)
     531                                                                streamurl1 = string_replace_all("\\", "", streamurl1, 1);
     532
     533                                                        if(streamurl1 == NULL) 
     534                                                        {                               
     535                                                                free(tmppath), tmppath = NULL;
     536                                                                free(tmphost), tmphost = NULL;
     537                                                                free(tmpurl), tmpurl = NULL;
     538                                                                tmpurl = string_resub("var url = '", "'", tmpstr, 0);
     539
     540                                                                if(tmpurl == NULL)
     541                                                                        tmpurl = string_resub("src='", "'", tmpstr, 0);
     542                                                                if(tmpurl == NULL)
     543                                                                        tmpurl = string_resub("src=\"", "\"", tmpstr, 0);
     544                                                               
     545                                                                if(ostrstr(tmpstr, "<h1>This channel can only work in") != NULL)
     546                                                                        referer = string_resub("<h1>This channel can only work in <a href='", "'", tmpstr, 0);
     547
     548                                                                free(tmpstr), tmpstr = NULL;           
     549                                                                tmphost = string_resub("http://", "/", tmpurl, 0);
     550                                                                tmppath = string_replace_all(tmphost, "", tmpurl, 0);
     551                                                                tmppath = string_replace_all("http://", "", tmppath, 1);
     552
     553                                                                send = ostrcat(NULL, "GET ", 0, 0);
     554                                                                send = ostrcat(send, tmppath, 1, 0);
     555                                                                send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: gzip\r\nHost: ", 1, 0);     
     556                                                                send = ostrcat(send, tmphost, 1, 0);
     557                                                                send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nConnection: close\r\n", 1, 0);     
     558                                                                send = ostrcat(send, "Referer: ", 1, 0);
     559                                                                send = ostrcat(send, referer, 1, 0);
     560                                                                send = ostrcat(send, "\r\nCookie: ", 1, 0);     
     561                                                                send = ostrcat(send, Cookie1, 1, 0);
     562                                                                send = ostrcat(send, "\r\n\r\n", 1, 0);
     563                                                                free(referer), referer = NULL;
     564
     565                                                                debug(99, ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;");                                                                                                       
     566                                                                debug(99, "send1: %s", send);
     567                                                                debug(99, ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;");                                                                                                       
     568
     569                                                                tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
     570                                                                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr7", oitoa(incount), tmphost, tmppath, tmpstr);
     571                                //                              free(tmppath), tmppath = NULL;
     572                                //                              free(tmphost), tmphost = NULL;
     573                                                                free(tmpurl), tmpurl = NULL;
     574
     575
     576                                                        }
     577
     578                                                        streamurl1 = string_resub("streamer: \"", "\"", tmpurl, 0);
     579                                                }
     580                                        }
     581                                }
    365582                                else
    366                                         title = ostrcat("Http Stream (", NULL, 0, 0);
    367 
     583                                {
     584                                        printf("found www\n");
     585
     586                                        free(tmppath), tmppath = NULL;
     587                                        free(tmphost), tmphost = NULL;
     588                                        free(tmpurl), tmpurl = NULL;
     589                                        tmpurl = string_resub("var url = '", "'", tmpstr, 0);
     590                                        free(tmpstr), tmpstr = NULL;           
     591                                       
     592                                        tmphost = string_resub("http://", "/", tmpurl, 0);
     593                                        tmppath = string_replace_all(tmphost, "", tmpurl, 0);
     594                                        tmppath = string_replace_all("http://", "", tmppath, 1);
     595                                }
     596
     597                                if(ostrstr(tmpstr, "<h1>This channel can only work in") != NULL)
     598                                {
     599                                        referer = string_resub("<h1>This channel can only work in <a href='", "'", tmpstr, 0);
     600                                }                                                               
     601
     602                                free(tmpstr), tmpstr = NULL;
     603                                free(send), send = NULL;
     604
     605                                send = ostrcat(NULL, "GET ", 0, 0);
     606                                send = ostrcat(send, tmppath, 1, 0);
     607                                send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: gzip\r\nHost: ", 1, 0);     
     608                                send = ostrcat(send, tmphost, 1, 0);
     609                                send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nConnection: close\r\n", 1, 0);     
     610                                send = ostrcat(send, "Referer: ", 1, 0);
     611                                if(referer != NULL)
     612                                        send = ostrcat(send, referer, 1, 0);
     613                                else
     614                                        send = ostrcat(send, tmphost, 1, 0);
     615                                send = ostrcat(send, "\r\nCookie: ", 1, 0);     
     616                                send = ostrcat(send, Cookie1, 1, 0);
     617                                send = ostrcat(send, "\r\n\r\n", 1, 0);
     618                               
     619                                free(referer), referer = NULL;
     620
     621                                printf("send2: %s\n", send);
     622                                debug(99, ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;");                                                                                                       
     623                                debug(99, "send2: %s", send);
     624                                debug(99, ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;");                                                                                                       
     625
     626                                                               
     627                                debug(199, "connect (%d) %s  %s", i, tmphost, tmppath);
     628                                tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
     629
     630                                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr8", oitoa(incount), tmphost, tmppath, tmpstr);
     631//                              free(tmppath), tmppath = NULL;
     632//                              free(tmphost), tmphost = NULL;
     633                                free(tmpurl), tmpurl = NULL;
     634
     635
     636                                swfUrl = string_resub("<script type=\"text/javascript\" src=\"", "\"", tmpstr, 0);
     637
     638                                if(ostrstr(tmpstr, "rtmpe://") != NULL)
     639                                {
     640                                        streamurl = getrtmp(tmpstr, tmphost, tmppath, &typemsg, fid, incount);
     641                                }
     642
     643                                free(tmphost), tmphost = NULL;                         
     644                                if(streamurl1 == NULL)
     645                                        streamurl1 = string_resub("file: \"", "\"", tmpstr, 0);                 
     646                       
     647                                if(streamurl1 == NULL)
     648                                {
     649                                        streamid = string_resub("stream=\"", "\"", tmpstr, 0);
     650                                        if(streamid != NULL)
     651                                        {
     652                                                tmpstr1 = string_resub("<div style=\"visibility:hidden;\">", "</body>", tmpstr, 0);                             
     653                                                tmpurl = string_resub("type=\"text/javascript\" src=\"", "\"", tmpstr1, 0);                             
     654
     655                                                tmphost = string_resub("http://", "/", tmpurl, 0);
     656                                                tmppath = string_replace_all(tmphost, "", tmpurl, 0);
     657                                                tmppath = string_replace_all("http://", "", tmppath, 1);
     658
     659                                                tmpstr = gethttp(tmphost, tmppath, 80, NULL, NULL, 10000, NULL, 0);
     660
     661                                                while(ostrstr(tmpstr, "\\") != NULL)
     662                                                {
     663                                                        tmpstr1 = string_resub("\"", "\"", tmpstr, 0);
     664                                                        tmpstr2 = string_replace_all("\\x", "%", tmpstr1, 0);
     665                                                       
     666                                                        if(tmpstr2 != NULL)
     667                                                        {
     668                                                                htmldecode(tmpstr2, tmpstr2);
     669
     670                                                                tmpstr3 = ostrcat("\"", tmpstr1, 0, 0);
     671                                                                tmpstr3 = ostrcat(tmpstr3, "\"", 1, 0);
     672
     673                                                                tmpstr4 = ostrcat("'", tmpstr2, 0, 0);
     674                                                                tmpstr4 = ostrcat(tmpstr4, "'", 1, 0);
     675
     676                                                                tmpstr = string_replace(tmpstr3, tmpstr4, tmpstr, 1);
     677                                                                free(tmpstr1), tmpstr1 = NULL;
     678                                                                free(tmpstr2), tmpstr2 = NULL;
     679                                                        }
     680                                                        else
     681                                                                break;
     682
     683                                                        free(tmpstr1), tmpstr1 = NULL;
     684                                                        free(tmpstr2), tmpstr2 = NULL;
     685                                                        free(tmpstr3), tmpstr3 = NULL;
     686                                                        free(tmpstr4), tmpstr4 = NULL;
     687                                                }
     688
     689
     690                                                titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr9", oitoa(incount), tmphost, tmppath, tmpstr);
     691                //                              free(tmppath), tmppath = NULL;
     692                //                              free(tmphost), tmphost = NULL;
     693                                                free(tmpurl), tmpurl = NULL;
     694
     695
     696                                                urlid = oregex(".*\\[(.*)\\]\\+stream.*", tmpstr);
     697                                                tokenid = oregex(".*securetoken:_0x.*\\[(.*)\\].*", tmpstr);
     698                                                pageurlid = oregex(".*abouttext:_0x.*\\[(.*)\\],width.*", tmpstr);
     699
     700                                                tmpstr1 = string_resub("[", "]", tmpstr, 0);
     701                                                int count2 = 0;
     702                                                struct splitstr* ret2 = NULL;
     703                                                ret2 = strsplit(tmpstr1, ",", &count2);
     704
     705                                                if(count2 > atoi(urlid)) url = string_resub("'", "'", ret2[atoi(urlid)].part, 0);
     706                                                if(count2 > atoi(tokenid)) token = string_resub("'", "'", ret2[atoi(tokenid)].part, 0);
     707                                                if(count2 > atoi(pageurlid)) pageurl = string_resub("'", "'", ret2[atoi(pageurlid)].part, 0);
     708
     709                                                printf("urlid: %s\n",urlid);
     710                                                printf("tokenid: %s\n",tokenid);
     711                                                printf("pageurlid: %s\n",pageurlid);
     712                                                printf("url: %s\n",url);
     713                                                printf("token: %s\n",token);
     714                                                printf("1pageurl: %s\n",pageurl);
     715
     716                                                free(ret2), ret2 = NULL;
     717
     718//rtmpdump -r rtmpe://strm.ukcast.tv/redirect -y bhousaa0 --debug
     719
     720                                                cmd = ostrcat("rtmpdump -r ", NULL, 0, 0);
     721                                                cmd = ostrcat(cmd, url, 1, 0);
     722                                                cmd = ostrcat(cmd, streamid, 1, 0);
     723                                                cmd = ostrcat(cmd, " --debug > /tmp/tithek/rtmp.log 2>&1", 1, 0);                                                                                               
     724                                                system("rm -rf /tmp/tithek/rtmp.log");
     725                                               
     726                                                free(tmpstr), tmpstr = NULL;
     727                                                printf("cmd: %s\n",cmd);
     728                                                system(cmd);
     729                                                free(cmd),cmd = NULL;
     730
     731                                                tmpstr = command("cat /tmp/tithek/rtmp.log");
     732
     733                                                streamip = string_resub("redirect, STRING:", ">", tmpstr, 0);
     734                                                strstrip(streamip);
     735
     736                                                free(tmpstr), tmpstr = NULL;
     737               
     738                                                streamurl = ostrcat(streamip, NULL, 0, 0);
     739                                                streamurl = ostrcat(streamurl, " playpath=", 1, 0);
     740                                                streamurl = ostrcat(streamurl, streamid, 1, 0);
     741//                                              streamurl = ostrcat(streamurl, " swfUrl=http://b17014255105be61b178-d8c0dbd82389bad2adcb7a22d1883b64.r92.cf5.rackcdn.com/jwplayer.flash.swf live=1 pageUrl=http://envivo.pw/ token=OOG17t.x#K9Vh#|", 1, 0);
     742
     743//                                              streamurl = ostrcat(streamurl, " swfUrl=http://b17014255105be61b178-d8c0dbd82389bad2adcb7a22d1883b64.r92.cf5.rackcdn.com/jwplayer.flash.swf", 1, 0);
     744                                                streamurl = ostrcat(streamurl, " swfUrl=", 1, 0);
     745                                                streamurl = ostrcat(streamurl, swfUrl, 1, 0);
     746                                                streamurl = ostrcat(streamurl, " live=1", 1, 0);
     747//                                              streamurl = ostrcat(streamurl, " pageUrl=http://envivo.pw/", 1, 0);
     748//                                              streamurl = ostrcat(streamurl, pageUrl, 1, 0);
     749                                                streamurl = ostrcat(streamurl, " pageUrl=http://", 1, 0);
     750                                                streamurl = ostrcat(streamurl, pageurl, 1, 0);
     751                                                streamurl = ostrcat(streamurl, "/", 1, 0);
     752//                                              typemsg = ostrcat(pageurl, NULL, 0, 0);
     753                                                       
     754                                                streamurl = ostrcat(streamurl, " token=", 1, 0);
     755                                                streamurl = ostrcat(streamurl, token, 1, 0);
     756                                               
     757                                                free(urlid), urlid = NULL;
     758                                                free(tokenid), tokenid = NULL;
     759                                                free(pageurlid), pageurlid = NULL;
     760                                                free(url), url = NULL;
     761                                                free(token), token = NULL;
     762                                                free(pageurl), pageurl = NULL;
     763                                               
     764                                        }
     765                                }
     766                                else
     767                                        streamurl = ostrcat(streamurl1, NULL, 0, 0);
     768
     769                                free(streamurl1), streamurl1 = NULL;
     770
     771                                title = ostrcat("Rtmpe Stream (", NULL, 0, 0);
    368772                                title = ostrcat(title, oitoa(incount), 1, 1);
    369773                                title = ostrcat(title, ")", 1, 0);
     
    381785                                        addmenulist(&mlist, title, streamurl, pic, 0, 0);
    382786                                }
    383 
     787                                free(channelid), channelid = NULL;
     788
     789                                free(streamip); streamip = NULL;
     790                                free(streamport); streamport = NULL;
     791                                free(streamid); streamid = NULL;
    384792                                free(title), title = NULL;
    385793                                free(pic), pic = NULL;
    386794                                free(streamurl), streamurl = NULL;
    387795                                free(typemsg), typemsg = NULL;
    388                                 free(url), url = NULL;
    389                                 free(host), host = NULL;
    390                                 free(path), path = NULL;
     796
     797                                www = 1;
    391798                                printf("####################### stop (%d) ############################\n", incount);
     799
     800
    392801                        }
    393802                }
     
    409818        }
    410819        free(tmpstr); tmpstr = NULL;
    411         free(host), host = NULL;
    412         free(path), path = NULL;
    413         free(url), url = NULL;
     820        free(ip), ip = NULL;
    414821
    415822        titheklog(debuglevel, "/var/usr/local/share/titan/plugins/tithek/tvtoast_tmpstr10_streamurl", NULL, NULL, NULL, tmpstr);
  • titan/skins/tithek/tithekmainmenu/mainmenu.list

    r36075 r36117  
    2626XXX-XVIDEOS#http://atemio.dyndns.tv/mediathek/mainmenu-xvideos.list#http://atemio.dyndns.tv/mediathek/menu/xvideos.jpg#xvideos.jpg#TiThek#1000
    2727Search (local)#http://atemio.dyndns.tv/mediathek/all/mainmenu-all.list#http://atemio.dyndns.tv/mediathek/menu/search.jpg#search.jpg#All#100
     28StreamLive#http://atemio.dyndns.tv/mediathek/mainmenu-streamlive.list#http://atemio.dyndns.tv/mediathek/menu/streamlive.jpg#streamlive.jpg#TiThek#0
Note: See TracChangeset for help on using the changeset viewer.