Changeset 45041


Ignore:
Timestamp:
12/20/20 21:32:33 (3 years ago)
Author:
obi
Message:

update tithek add useproxy add delservice to settings

Location:
titan
Files:
6 edited

Legend:

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

    r44942 r45041  
    11#define HTTPAUTH "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0="
     2#define HTTPUSER "aUtzhFRTzuDFa"
     3#define HTTPPASS "JNHZbghnjuz"
    24
    35
  • titan/plugins/tithek/tithek.h

    r44955 r45041  
    667667        if(ostrncmp("http://", link, 7) && ostrncmp("https://", link, 8) && ostrncmp("/tmp/localhoster/hoster.sh", link, 26)) return NULL;
    668668
    669 //    link = stringreplacecharonce(link, '"', '\0');
    670 //    link = stringreplacecharonce(link, ' ', '\0');
     669        link = stringreplacecharonce(link, ' ', '\0');
    671670
    672671        if(!ostrncmp("/tmp/localhoster/hoster.sh", link, 26))
     
    747746                                        if(dnode != NULL)
    748747                                        {
    749 //                                      if(ssl == 1)
     748//+                                     if(ssl == 1)
    750749//                                                      dnode->link = ostrcat(link, NULL, 0, 0);
    751750                                                if(usecmd == 1)
     
    20902089                                }
    20912090//#endif
    2092                                 if(!ostrncmp("http://", tmpstr1, 7) && (file_exist(getconfig("rec_streampath", NULL)) && (file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack"))))
     2091                                if((!ostrncmp("http://", tmpstr1, 7) || !ostrncmp("https://", tmpstr1, 8)) && (file_exist(getconfig("rec_streampath", NULL)) && (file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack"))))
    20932092//                              if(!ostrncmp("http", tmpstr1, 4) && (file_exist(getconfig("rec_streampath", NULL)) && (file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack"))))
    20942093                                {
     
    21222121                        screenplay(tmpstr1, filename, 2, flag);
    21232122                        delconfigtmp("playerbuffersize");
     2123                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2124                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21242125                }
    21252126                else if(ostrcmp(keyconf, "Streaming Playback Caching (0.5MB)") == 0)
     
    21282129                        screenplay(tmpstr1, filename, 2, flag);
    21292130                        delconfigtmp("playerbuffersize");
     2131                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2132                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21302133                }
    21312134                else if(ostrcmp(keyconf, "Streaming Playback Caching (1MB)") == 0)
     
    21342137                        screenplay(tmpstr1, filename, 2, flag);
    21352138                        delconfigtmp("playerbuffersize");
     2139                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2140                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21362141                }
    21372142                else if(ostrcmp(keyconf, "Streaming Playback Caching (2MB)") == 0)
     
    21402145                        screenplay(tmpstr1, filename, 2, flag);
    21412146                        delconfigtmp("playerbuffersize");
     2147                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2148                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21422149                }
    21432150                else if(ostrcmp(keyconf, "Streaming Playback Caching (3MB)") == 0)
     
    21462153                        screenplay(tmpstr1, filename, 2, flag);
    21472154                        delconfigtmp("playerbuffersize");
     2155                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2156                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21482157                }
    21492158                else if(ostrcmp(keyconf, "Streaming Playback Caching (4MB)") == 0)
     
    21522161                        screenplay(tmpstr1, filename, 2, flag);
    21532162                        delconfigtmp("playerbuffersize");
     2163                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2164                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21542165                }
    21552166                else if(ostrcmp(keyconf, "Streaming Playback Caching (5MB)") == 0)
     
    21582169                        screenplay(tmpstr1, filename, 2, flag);
    21592170                        delconfigtmp("playerbuffersize");
     2171                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2172                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21602173                }
    21612174                else if(ostrcmp(keyconf, "Streaming Playback Caching (7.5MB)") == 0)
     
    21642177                        screenplay(tmpstr1, filename, 2, flag);
    21652178                        delconfigtmp("playerbuffersize");
     2179                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2180                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21662181                }
    21672182                else if(ostrcmp(keyconf, "Streaming Playback Caching (10MB)") == 0)
     
    21702185                        screenplay(tmpstr1, filename, 2, flag);
    21712186                        delconfigtmp("playerbuffersize");
     2187                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2188                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21722189                }
    21732190                else if(ostrcmp(keyconf, "File Caching Playback (10MB / 120s)") == 0)
    21742191                {
    21752192                        cacheplay(tmpstr1, filename, 1);
     2193                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2194                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21762195                }
    21772196                else if(ostrcmp(keyconf, "File Caching Playback (20MB / 240s)") == 0)
    21782197                {
    21792198                        cacheplay(tmpstr1, filename, 2);
     2199                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2200                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21802201                }
    21812202                else if(ostrcmp(keyconf, "File Caching Playback (30MB / 360s)") == 0)
    21822203                {
    21832204                        cacheplay(tmpstr1, filename, 3);
     2205                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2206                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    21842207                }
    21852208                else if(ostrcmp(keyconf, "Download Full File") == 0)
     
    21982221                                        screenplay(tmpstr2, filename, 2, flag);
    21992222                                        free(tmpstr2); tmpstr2 = NULL;
     2223                                        if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 0)
     2224                                                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    22002225                                }
    22012226                        }
     
    22752300
    22762301                mkdir("/tmp/tithek", 777);
    2277                 if(status.mcaktiv == 0)
     2302                if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 1)
    22782303                {
    22792304                        rcret = servicestop(status.aktservice, 1, 1);
     
    32883313                python = 0;
    32893314
    3290                 if(status.mcaktiv == 0)
     3315                if(status.mcaktiv == 0 && getconfigint("tithek_delservice", NULL) == 1)
    32913316                        servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
    32923317        }
  • titan/plugins/tithek/tithek_global.h

    r45037 r45041  
    246246}
    247247
     248#include <stdio.h>
     249#include <curl/curl.h>
     250
     251/* This callback is, currently, a simple wrapper around fwrite(). You
     252   could get it to write to memory, or do anything else you'd like
     253   with the output. For more info, see
     254   http://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html
     255 */
     256
    248257struct MemoryStruct {
    249258  char *memory;
    250   size_t size;
     259  size_t size; 
    251260};
    252261
     
    259268  mem->memory = realloc(mem->memory, mem->size + realsize + 1);
    260269  if(mem->memory == NULL) {
    261     /* out of memory! */
    262     printf("not enough memory (realloc returned NULL)\n");
    263     return 0;
     270        /* out of memory! */
     271        printf("not enough memory (realloc returned NULL)\n");
     272        return 0;
    264273  }
    265274 
     
    271280}
    272281
     282static size_t writeCallback(void *contents, size_t size, size_t nitems, FILE *file) {
     283  return fwrite(contents, size, nitems, file);
     284}
    273285// flag = 0 (without header in output)
    274286// flag = 1 (with header in output)
     
    276288{
    277289        debug(99, "url: %s", url);
    278 //    if(ostrncmp("http", url, 4)) return NULL;
     290        printf("url: %s\n", url);
    279291
    280292        int debuglevel = getconfigint("debuglevel", NULL);
     
    297309        if(curl_handle)
    298310        {
    299             if(localfile != NULL)
     311                if(localfile != NULL)
    300312                    fp = fopen(localfile,"wb");
    301313               
     
    305317                if(user != NULL && pass != NULL)
    306318                {
    307                         curl_easy_setopt(curl_handle, CURLOPT_USERNAME, user);
    308                         curl_easy_setopt(curl_handle, CURLOPT_PASSWORD, pass);
     319                        curl_easy_setopt(curl_handle, CURLOPT_USERNAME, HTTPUSER);
     320                        curl_easy_setopt(curl_handle, CURLOPT_PASSWORD, HTTPPASS);
    309321                        curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    310322                }
     
    317329
    318330                        /* example.com is redirected, so we tell libcurl to send POST on 301, 302 and
    319                      303 HTTP response codes */
     331                        303 HTTP response codes */
    320332                        curl_easy_setopt(curl_handle, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
    321333                }
     
    326338//              curl_easy_setopt(curl_handle, CURLOPT_RETURNTRANSFER, 1);
    327339
    328                 /* send all data to this function  */
    329             if(localfile == NULL)
     340                if(localfile == NULL)
     341                {
     342                        /* send all data to this function  */
    330343                        curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
     344                }
    331345                else
    332                         curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, NULL);
    333 
    334                 /* we pass our 'chunk' struct to the callback function */
    335             if(localfile == NULL)
     346                {
     347                        /* When data arrives, curl will call writeCallback. */
     348                        curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeCallback);
     349//                      curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, NULL);             
     350                }
     351
     352
     353
     354                if(localfile == NULL)
     355                {
     356                        /* we pass our 'chunk' struct to the callback function */
    336357                        curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
     358                }
    337359                else
    338                         curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, fp);
     360                {
     361                        /* The last argument to writeCallback will be our file: */
     362                        curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)fp);
     363                }
    339364
    340365                /* some servers don't like requests that are made without a user-agent field, so we provide one */
     
    362387                curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L);
    363388
     389
    364390                /* enable all supported built-in compressions */
    365391                curl_easy_setopt(curl_handle, CURLOPT_ACCEPT_ENCODING, "");
     
    370396                        curl_easy_setopt(curl_handle, CURLOPT_REFERER, referer);
    371397
    372                 if(getconfig("tithek_proxy", NULL) != NULL)
     398                if(getconfig("tithek_proxy", NULL) != NULL && getconfigint("tithek_useproxy", NULL) == 1)
    373399                        curl_easy_setopt(curl_handle, CURLOPT_PROXY, getconfig("tithek_proxy", NULL));
    374400
    375401                /* get it! */
    376402                res = curl_easy_perform(curl_handle);
     403
    377404                /* check for errors */
    378405                if(res != CURLE_OK)
     
    398425        }
    399426
    400         tmpstr = ostrcat(chunk.memory, NULL, 0, 0);
     427        if(localfile == NULL)
     428                tmpstr = ostrcat(chunk.memory, NULL, 0, 0);
     429
    401430        free(chunk.memory);
    402         /* we're done with libcurl, so clean it up */
    403         curl_global_cleanup();
    404 
    405         if(localfile != NULL)
     431        /* we're done with libcurl, so clean it up */
     432
     433        curl_global_cleanup();
     434
     435        if(localfile != NULL)
    406436                free(tmpstr), tmpstr = NULL;
     437
    407438        return tmpstr;
    408439}
  • titan/plugins/tithek/tithek_settings.h

    r45037 r45041  
    2121        struct skin* kinox_pic = getscreennode(tithek_settings, "kinox_pic");
    2222        struct skin* kinox_localhoster = getscreennode(tithek_settings, "kinox_localhoster");
     23        struct skin* useproxy = getscreennode(tithek_settings, "useproxy");
    2324        struct skin* proxy = getscreennode(tithek_settings, "proxy");
     25        struct skin* delservice = getscreennode(tithek_settings, "delservice");
    2426       
    2527        struct skin* autoupdate = getscreennode(tithek_settings, "autoupdate");
     
    9193        changeinput(kinox_url, getconfig("tithek_kinox_url", NULL));
    9294
    93         changemask(proxy, "abcdefghijklmnopqrstuvwxyz0123456789://@");
    94         changeinput(proxy, getconfig("tithek_proxy", NULL));
    95 
    9695        addchoicebox(kinox_pic, "0", _("no"));
    9796        addchoicebox(kinox_pic, "1", _("yes"));
     
    102101        addchoicebox(kinox_localhoster, "2", _("cloudfare"));   
    103102        setchoiceboxselection(kinox_localhoster, getconfig("tithek_kinox_localhoster", NULL));
     103
     104        changemask(proxy, "abcdefghijklmnopqrstuvwxyz0123456789://@");
     105        changeinput(proxy, getconfig("tithek_proxy", NULL));
     106
     107        addchoicebox(useproxy, "0", _("no"));
     108        addchoicebox(useproxy, "1", _("yes")); 
     109        setchoiceboxselection(useproxy, getconfig("tithek_useproxy", NULL));
     110
     111        addchoicebox(delservice, "0", _("no"));
     112        addchoicebox(delservice, "1", _("yes"));       
     113        setchoiceboxselection(delservice, getconfig("tithek_delservice", NULL));
    104114
    105115        if(!file_exist("/mnt/swapextensions/etc/.codecpack") && !file_exist("/var/swap/etc/.codecpack") && !file_exist("/var/etc/.codecpack"))
     
    118128                rcret = waitrc(tithek_settings, 0, 0);
    119129                tmp = listbox->select;
    120        
     130/*
     131                if(useproxy->ret != NULL && ostrcmp(useproxy->ret, "0") == 0)
     132                        proxy->hidden = YES;
     133                else
     134                        proxy->hidden = NO;
     135*/             
    121136                if(rcret == getrcconfigint("rcexit", NULL)) break;
    122137                if(rcret == getrcconfigint("rcok", NULL))
     
    131146                        addconfigscreencheck("tithek_kinox_pic", kinox_pic, NULL);
    132147                        addconfigscreencheck("tithek_kinox_localhoster", kinox_localhoster, NULL);
     148                        addconfigscreencheck("tithek_useproxy", useproxy, NULL);
    133149                        addconfigscreen("tithek_proxy", proxy);
     150                        addconfigscreencheck("tithek_delservice", delservice, NULL);
    134151/*
    135152                        if(amazon_user->ret != NULL && ostrcmp(amazon_user->ret, "****") != 0)
     
    193210                {
    194211                        unlink("/mnt/network/cookies");
     212                }
     213                else if(rcret == getrcconfigint("rcyellow", NULL))
     214                {
     215                        char* tmpstr = NULL;
     216                        char* cmd = NULL;
     217                        if(kinox_localhoster->ret != NULL && ostrcmp(kinox_localhoster->ret, "0") == 0)
     218                                tmpstr = gethttp("checkip.dyndns.org", "/", 80, NULL, NULL, 10000, NULL, 0);
     219                        else if(kinox_localhoster->ret != NULL && ostrcmp(kinox_localhoster->ret, "1") == 0)
     220                                tmpstr = gethttps("http://checkip.dyndns.org/", NULL, NULL, NULL, NULL, NULL, 1);
     221                        else if(kinox_localhoster->ret != NULL && ostrcmp(kinox_localhoster->ret, "2") == 0)
     222                        {
     223        // new start
     224                                cmd = ostrcat("/tmp/localhoster/hoster.sh cloudflare 'http://checkip.dyndns.org/'", NULL, 0, 0);
     225                                debug(99, "cmd: %s", cmd);
     226
     227                                tmpstr = command(cmd);
     228                                free(cmd), cmd = NULL;
     229        // new end
     230                        }
     231                        cmd = string_resub("<body>", "</body>", tmpstr, 0);
     232                        free(tmpstr), tmpstr = NULL;
     233
     234                        textbox(_("Message"), cmd, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 0, 0);
     235                        free(cmd), cmd = NULL;
    195236                }
    196237
  • titan/skins/tithek/skin.xml

    r45037 r45041  
    3737                <node parent="listbox" name="kinox_pic" text="KinoX Load Preview Pic" type="choicebox" valign="middle" width="100%" height="35">
    3838                <node parent="listbox" name="kinox_localhoster" text="KinoX Localhoster" type="choicebox" valign="middle" width="100%" height="35">
     39                <node parent="listbox" name="useproxy" text="Use Proxy" type="choicebox" valign="middle" width="100%" height="35">
    3940                <node parent="listbox" name="proxy" text="Proxy" type="inputbox" valign="middle" width="100%" height="35">
     41                <node parent="listbox" name="delservice" text="Del Service" type="choicebox" valign="middle" width="100%" height="35">
    4042        <node name="buttonbar" posx="0" posy="0" width="100%" height="50" hspace="5" fontcol="black" fontsize="25" bordercol="titlebgcol" bordersize="1" borderradius="8" bgcol="titlebgcol" bgcol2="white" gradient="topmiddle">
    4143                <node parent="buttonbar" name="b1" picmem="skin/key_ok_70x40.png"    posx="0"   posy="center" width="70" height="40">
     
    4446                <node parent="buttonbar" name="b4" picmem="skin/key_red_30x30.png" posx="220" posy="center" width="280" height="30" valign="middle" textposx="40" text="Remove Cookies">
    4547                <node parent="buttonbar" name="b5" picmem="skin/key_green_30x30.png" posx="440" posy="center" width="280" height="30" valign="middle" textposx="40" text="Screensaver">
     48                <node parent="buttonbar" name="b6" picmem="skin/key_yellow_30x30.png" posx="680" posy="center" width="280" height="30" valign="middle" textposx="40" text="Current IP Check">
    4649</screen>
    4750
  • titan/titan/struct.h

    r45027 r45041  
    703703        char* filename;
    704704        char* auth;
     705        char* user;
     706        char* pass;
    705707        int connfd;
    706708        int proz;
Note: See TracChangeset for help on using the changeset viewer.