Changeset 25053 for titan/plugins/imdb


Ignore:
Timestamp:
11/30/13 17:06:12 (9 years ago)
Author:
obi
Message:

fix imdb

File:
1 edited

Legend:

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

    r20034 r25053  
    3535struct imdb* getimdb(struct imdb** first, char* input, int flag, int flag1, int flag2)
    3636{
    37         char* tmpstr = NULL, *tmpsearch = NULL, *savefile = NULL, *pageposter = NULL, *title = NULL;
     37        char* tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL, *tmpsearch = NULL, *savefile = NULL, *pageposter = NULL, *title = NULL;
    3838
    3939        debug(133, "title: %s",input);
     
    6767
    6868        tmpstr = gethttp("www.imdb.de", tmpsearch, 80, NULL, NULL, 5000, NULL, 0);
     69//      writesys("/var/usr/local/share/titan/plugins/imdb/tmpstr0", tmpstr, 1);
     70
    6971       
    7072        debug(133, "tmpsearch: %s", tmpsearch);
     
    125127
    126128                        struct menulist* mlist = NULL, *mbox = NULL;
    127                         char* tmpstr1 = NULL;
    128129                       
    129130                        int count = 0;
     
    213214       
    214215                        tmpstr = gethttp("www.imdb.de", tmpsearch, 80, NULL, NULL, 5000, NULL, 0);
     216//                      writesys("/var/usr/local/share/titan/plugins/imdb/tmpstrj", tmpstr, 0);
    215217                       
    216218                        debug(133, "tmpsearch: %s", tmpsearch);
     
    222224        {
    223225                if(ostrstr(tmpstr, "<title>") != NULL)
    224                 {
     226                {               
    225227                        (*first)->title = string_resub("<title>", "</title>", tmpstr, 0);
    226228                        (*first)->title = string_decode((*first)->title, 1);
     
    229231                }
    230232
    231                 if(ostrstr(tmpstr, "<h5>Genre:</h5>") != NULL)
    232                 {
    233                         (*first)->genre = string_resub("<h5>Genre:</h5>", "</div>", tmpstr, 0);
    234                         (*first)->genre = string_decode((*first)->genre, 1);
     233                if(ostrstr(tmpstr, "\"genre\">") != NULL)
     234                {
     235                        tmpstr1 = string_resub("&nbsp;-&nbsp;", "</div>", tmpstr, 0);
     236
     237                        while(ostrstr(tmpstr1, "\"genre\"") != NULL)
     238                        {
     239                                tmpstr2 = string_resub("\"genre\">", "</span>", tmpstr1, 0);
     240                                tmpstr1 = string_replace("\"genre\">", "", tmpstr1, 1);
     241                                if((*first)->genre != NULL && tmpstr2 != NULL)
     242                                        (*first)->genre = ostrcat((*first)->genre, ",", 1, 0);
     243
     244                                (*first)->genre = ostrcat((*first)->genre, tmpstr2, 1, 0);
     245                                free(tmpstr2), tmpstr2 = NULL;
     246                        }
     247                        free(tmpstr1), tmpstr1 = NULL;
     248
    235249                        string_striptags((*first)->genre);
    236250                        string_strip_whitechars((*first)->genre);
    237251                        strstrip((*first)->genre);
    238252                }
    239 
    240                 if(ostrstr(tmpstr, "<h5>Drehbuchautor") != NULL)
    241                 {
    242                         char* tmp = NULL;
    243 
    244                         (*first)->writer = string_resub("<h5>Drehbuchautor", "</div>", tmpstr, 0);
    245                         tmp = (*first)->writer;
    246                         (*first)->writer = string_resub("<div class=\"info-content\">", "</div>", (*first)->writer, 0);
    247                         free(tmp); tmp = (*first)->writer;
    248                         (*first)->writer = string_resub(";\">", "</a>", (*first)->writer, 0);
    249                         free(tmp); tmp = NULL;
    250                         (*first)->writer = string_decode((*first)->writer, 1);
     253                       
     254                if(ostrstr(tmpstr, ">Writers:</h4>") != NULL)
     255                {
     256                        tmpstr1 = string_resub(">Writers:</h4>", "</div>", tmpstr, 0);
     257
     258                        while(ostrstr(tmpstr1, "\"name\"") != NULL)
     259                        {
     260                                tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0);
     261                                tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1);
     262                                if((*first)->writer != NULL && tmpstr2 != NULL)
     263                                        (*first)->writer = ostrcat((*first)->writer, ",", 1, 0);
     264
     265                                (*first)->writer = ostrcat((*first)->writer, tmpstr2, 1, 0);
     266                                free(tmpstr2), tmpstr2 = NULL;
     267                        }
     268                        free(tmpstr1), tmpstr1 = NULL;
     269
    251270                        string_striptags((*first)->writer);
    252271                        string_strip_whitechars((*first)->writer);
     
    254273                }
    255274
    256                 if(ostrstr(tmpstr, "Regisseur:") != NULL)
    257                 {
    258                         char* tmp = NULL;
    259 
    260                         (*first)->director = string_resub("Regisseur:", "</div>", tmpstr, 0);
    261                         tmp = (*first)->director;
    262                         (*first)->director = string_resub(";\">", "</a><br/>", (*first)->director, 0);
    263                         free(tmp); tmp = NULL;
    264                         (*first)->director = string_decode((*first)->director, 1);
     275                if((*first)->writer == NULL && ostrstr(tmpstr, ">Writer:</h4>") != NULL)
     276                {
     277                        tmpstr1 = string_resub(">Writer:</h4>", "</div>", tmpstr, 0);
     278
     279                        while(ostrstr(tmpstr1, "\"name\"") != NULL)
     280                        {
     281                                tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0);
     282                                tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1);
     283                                if((*first)->writer != NULL && tmpstr2 != NULL)
     284                                        (*first)->writer = ostrcat((*first)->writer, ",", 1, 0);
     285
     286                                (*first)->writer = ostrcat((*first)->writer, tmpstr2, 1, 0);
     287                                free(tmpstr2), tmpstr2 = NULL;
     288                        }
     289                        free(tmpstr1), tmpstr1 = NULL;
     290
     291                        string_striptags((*first)->writer);
     292                        string_strip_whitechars((*first)->writer);
     293                        strstrip((*first)->writer);
     294                }
     295
     296                if(ostrstr(tmpstr, ">Director:</h4>") != NULL)
     297                {
     298                        tmpstr1 = string_resub(">Director:</h4>", "</div>", tmpstr, 0);
     299
     300                        while(ostrstr(tmpstr1, "\"name\"") != NULL)
     301                        {
     302                                tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0);
     303                                tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1);
     304                                if((*first)->director != NULL && tmpstr2 != NULL)
     305                                        (*first)->director = ostrcat((*first)->director, ",", 1, 0);
     306
     307                                (*first)->director = ostrcat((*first)->director, tmpstr2, 1, 0);
     308                                free(tmpstr2), tmpstr2 = NULL;
     309                        }
     310                        free(tmpstr1), tmpstr1 = NULL;
     311
    265312                        string_striptags((*first)->director);
    266313                        string_strip_whitechars((*first)->director);
    267314                        strstrip((*first)->director);
    268315                }
    269                
    270                 if(ostrstr(tmpstr, "<h5>Premierendatum:</h5>") != NULL)
    271                 {
    272                         char* tmp = NULL;
    273 
    274                         (*first)->released = string_resub("<h5>Premierendatum:</h5>", "<a class=", tmpstr, 0);
    275                         tmp = (*first)->released;
    276                         (*first)->released = string_resub("<div class=\"info-content\">", "<a class=", (*first)->released, 0);
    277                         free(tmp); tmp = NULL;
    278                         (*first)->released = string_decode((*first)->released, 1);
     316
     317                if((*first)->director == NULL && ostrstr(tmpstr, ">Directors:</h4>") != NULL)
     318                {
     319                        tmpstr1 = string_resub(">Directors:</h4>", "</div>", tmpstr, 0);
     320
     321                        while(ostrstr(tmpstr1, "\"name\"") != NULL)
     322                        {
     323                                tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0);
     324                                tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1);
     325                                if((*first)->director != NULL && tmpstr2 != NULL)
     326                                        (*first)->director = ostrcat((*first)->director, ",", 1, 0);
     327
     328                                (*first)->director = ostrcat((*first)->director, tmpstr2, 1, 0);
     329                                free(tmpstr2), tmpstr2 = NULL;
     330                        }
     331                        free(tmpstr1), tmpstr1 = NULL;
     332
     333                        string_striptags((*first)->director);
     334                        string_strip_whitechars((*first)->director);
     335                        strstrip((*first)->director);
     336                }
     337
     338                if((*first)->director == NULL && ostrstr(tmpstr, "<b>Director:</b>") != NULL)
     339                {
     340                        (*first)->director = string_resub("<b>Director:</b>", "</div>", tmpstr, 0);
     341                        string_striptags((*first)->director);
     342                        string_strip_whitechars((*first)->director);
     343                        strstrip((*first)->director);
     344                }
     345
     346                if((*first)->director == NULL && ostrstr(tmpstr, ">Creator:</h4>") != NULL)
     347                {
     348                        tmpstr1 = string_resub(">Creator:</h4>", "</div>", tmpstr, 0);
     349
     350                        while(ostrstr(tmpstr1, "\"name\"") != NULL)
     351                        {
     352                                tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0);
     353                                tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1);
     354                                if((*first)->director != NULL && tmpstr2 != NULL)
     355                                        (*first)->director = ostrcat((*first)->director, ",", 1, 0);
     356
     357                                (*first)->director = ostrcat((*first)->director, tmpstr2, 1, 0);
     358                                free(tmpstr2), tmpstr2 = NULL;
     359                        }
     360                        free(tmpstr1), tmpstr1 = NULL;
     361
     362                        string_striptags((*first)->director);
     363                        string_strip_whitechars((*first)->director);
     364                        strstrip((*first)->director);
     365                }
     366
     367                if((*first)->director == NULL && ostrstr(tmpstr, ">Creators:</h4>") != NULL)
     368                {
     369                        tmpstr1 = string_resub(">Creators:</h4>", "</div>", tmpstr, 0);
     370
     371                        while(ostrstr(tmpstr1, "\"name\"") != NULL)
     372                        {
     373                                tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0);
     374                                tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1);
     375                                if((*first)->director != NULL && tmpstr2 != NULL)
     376                                        (*first)->director = ostrcat((*first)->director, ",", 1, 0);
     377
     378                                (*first)->director = ostrcat((*first)->director, tmpstr2, 1, 0);
     379                                free(tmpstr2), tmpstr2 = NULL;
     380                        }
     381                        free(tmpstr1), tmpstr1 = NULL;
     382
     383                        string_striptags((*first)->director);
     384                        string_strip_whitechars((*first)->director);
     385                        strstrip((*first)->director);
     386                }
     387
     388                if(ostrstr(tmpstr, ">Release Date:</h4>") != NULL)
     389                {
     390                        (*first)->released = string_resub(">Release Date:</h4>", "<span", tmpstr, 0);
    279391                        string_striptags((*first)->released);
    280392                        string_strip_whitechars((*first)->released);
     
    282394                }
    283395
    284                 if(ostrstr(tmpstr, "<h3>Besetzung</h3>") != NULL)
    285                 {
    286                         char* tmp = NULL;
    287 
    288                         (*first)->actors = string_resub("<h3>Besetzung</h3>&nbsp;", "</td></tr></table>", tmpstr, 0);
    289                         tmp = (*first)->actors;
    290                         (*first)->actors = string_resub("<div class=\"info-content block\"><table class=\"cast\">", "</a></td></tr>", (*first)->actors, 0);
    291                         free(tmp); tmp = NULL;
    292                         (*first)->actors = string_replace("...", "als", (*first)->actors, 1);
    293                         (*first)->actors = string_decode((*first)->actors,1);
     396                if(ostrstr(tmpstr, ">Star:</h4>") != NULL)
     397                {
     398                        tmpstr1 = string_resub(">Star:</h4>", "</div>", tmpstr, 0);
     399
     400                        while(ostrstr(tmpstr1, "\"name\"") != NULL)
     401                        {
     402                                tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0);
     403                                tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1);
     404                                if((*first)->actors != NULL && tmpstr2 != NULL)
     405                                        (*first)->actors = ostrcat((*first)->actors, ",", 1, 0);
     406
     407                                (*first)->actors = ostrcat((*first)->actors, tmpstr2, 1, 0);
     408                                free(tmpstr2), tmpstr2 = NULL;
     409                        }
     410                        free(tmpstr1), tmpstr1 = NULL;
     411
    294412                        string_striptags((*first)->actors);
    295413                        string_strip_whitechars((*first)->actors);
     
    297415                }
    298416
    299                 if(ostrstr(tmpstr, "<a name=\"poster\" href=\"") != NULL)
    300                 {
    301                         char* tmp = NULL;
    302 
    303                         (*first)->thumb = string_resub("<a name=\"poster\" href=\"", "\" /></a>", tmpstr, 0);
    304                         tmp = (*first)->thumb;
    305                         (*first)->thumb = string_resub("src=\"", "\" /></a>", (*first)->thumb, 0);
    306                         free(tmp); tmp = NULL;
     417                if(ostrstr(tmpstr, ">Stars:</h4>") != NULL)
     418                {
     419                        tmpstr1 = string_resub(">Stars:</h4>", "</div>", tmpstr, 0);
     420
     421                        while(ostrstr(tmpstr1, "\"name\"") != NULL)
     422                        {
     423                                tmpstr2 = string_resub("\"name\">", "</span>", tmpstr1, 0);
     424                                tmpstr1 = string_replace("\"name\">", "", tmpstr1, 1);
     425                                if((*first)->actors != NULL && tmpstr2 != NULL)
     426                                        (*first)->actors = ostrcat((*first)->actors, ",", 1, 0);
     427
     428                                (*first)->actors = ostrcat((*first)->actors, tmpstr2, 1, 0);
     429                                free(tmpstr2), tmpstr2 = NULL;
     430                        }
     431                        free(tmpstr1), tmpstr1 = NULL;
     432
     433                        string_striptags((*first)->actors);
     434                        string_strip_whitechars((*first)->actors);
     435                        strstrip((*first)->actors);
     436                }
     437
     438                if(ostrstr(tmpstr, "\"description\">") != NULL)
     439                {
     440                        tmpstr1 = string_resub("\"description\">", "</div>", tmpstr, 0);
     441                        (*first)->plot = string_resub("<p>", "</p>", tmpstr1, 0);
     442                }
     443       
     444                if(ostrstr(tmpstr, "<meta property='og:image' content=\"") != NULL)
     445                {
     446                        (*first)->thumb = string_resub("<meta property='og:image' content=\"", "\"", tmpstr, 0);
    307447                }
    308448
     
    338478        }
    339479
    340         if(*first != NULL && (*first)->id == NULL)
     480//      if(*first != NULL && (*first)->id == NULL)
     481        if(*first != NULL && (*first)->id != NULL)
    341482        {
    342483                tmpsearch = ostrcat("/title/tt", NULL, 0, 0);
     
    345486
    346487                tmpstr = gethttp("www.imdb.de", tmpsearch, 80, NULL, NULL, 5000, NULL, 0);
     488//              writesys("/var/usr/local/share/titan/plugins/imdb/tmpstrplot", tmpstr, 0);
    347489               
    348490                debug(133, "tmpsearch: %s", tmpsearch);
     
    353495        if(*first != NULL && tmpstr != NULL)
    354496        {
    355                 if(ostrstr(tmpstr, "swiki.2.1") != NULL)
    356                 {
    357                         (*first)->plot = string_resub("<div id=\"swiki.2.1\">", "</div>", tmpstr, 0);
    358                         (*first)->plot = string_decode((*first)->plot, 1);
    359                         string_striptags((*first)->plot);
    360                         string_strip_whitechars((*first)->plot);
    361                         strstrip((*first)->plot);
     497                if(ostrstr(tmpstr, "<p class=\"plotSummary\">") != NULL)
     498                {
     499                        tmpstr1 = string_resub("<p class=\"plotSummary\">", "<span", tmpstr, 0);
     500                        if(tmpstr1 != NULL)
     501                        {
     502                                (*first)->plot = ostrcat((*first)->plot, tmpstr1, 1, 0);
     503                                string_striptags((*first)->plot);
     504                                string_strip_whitechars((*first)->plot);
     505                                strstrip((*first)->plot);
     506                        }
     507                        free(tmpstr1), tmpstr1 = NULL;
    362508                }
    363509                free(tmpstr), tmpstr = NULL;
    364510        }
    365 
     511               
    366512        if(flag2 == 0 && *first != NULL && (*first)->id != NULL)
    367513        {
Note: See TracChangeset for help on using the changeset viewer.