Ticket #1884: comhem-fixup.diff
File comhem-fixup.diff, 17.2 KB (added by , 19 years ago) |
---|
-
libs/libmythtv/eit.cpp
279 279 QString lsubtitle = subtitle; 280 280 QString ldesc = description; 281 281 QString lcategory = category; 282 QString lairdate = airdate; 283 QDate loriginalairdate = originalairdate; 282 284 283 285 if (match.title.length() >= ltitle.length()) 284 286 ltitle = match.title; … … 292 294 if (lcategory.isEmpty() && !match.category.isEmpty()) 293 295 lcategory = match.category; 294 296 297 if (lairdate.isEmpty() && !match.airdate.isEmpty()) 298 lairdate = match.airdate; 299 300 if (loriginalairdate.isNull() && !match.originalairdate.isNull()) 301 loriginalairdate = match.originalairdate; 302 295 303 uint tmp = category_type; 296 304 if (!category_type && match.category_type) 297 305 tmp = match.category_type; … … 317 325 " closecaptioned = :CC, subtitled = :SUBTITLED, " 318 326 " stereo = :STEREO, hdtv = :HDTV, " 319 327 " partnumber = :PARTNO, parttotal = :PARTTOTAL, " 320 " listingsource = :LSOURCE " 328 " listingsource = :LSOURCE, airdate = :AIRDATE, " 329 " originalairdate = :ORGAIRDATE " 321 330 "WHERE chanid = :CHANID AND " 322 331 " starttime = :OLDSTART "); 323 332 … … 337 346 query.bindValue(":PARTNO", lpartnumber); 338 347 query.bindValue(":PARTTOTAL", lparttotal); 339 348 query.bindValue(":LSOURCE", 1); 349 query.bindValue(":AIRDATE", lairdate=="" ? "0000" : lairdate); 350 query.bindValue(":ORGAIRDATE", loriginalairdate); 340 351 341 352 if (!query.exec()) 342 353 { … … 458 469 " starttime, endtime, " 459 470 " closecaptioned, subtitled, stereo, hdtv, " 460 471 " partnumber, parttotal, " 461 " listingsource ) "472 " listingsource, airdate, originalairdate ) " 462 473 "VALUES (" 463 474 " :CHANID, :TITLE, :SUBTITLE, :DESCRIPTION, " 464 475 " :CATEGORY, :CATTYPE, " 465 476 " :STARTTIME, :ENDTIME, " 466 477 " :CC, :SUBTITLED, :STEREO, :HDTV, " 467 478 " :PARTNUMBER, :PARTTOTAL, " 468 " :LSOURCE ) ");479 " :LSOURCE, :AIRDATE, :ORGAIRDATE ) "); 469 480 470 481 QString cattype = myth_category_type_to_string(category_type); 471 482 … … 484 495 query.bindValue(":PARTNUMBER", partnumber); 485 496 query.bindValue(":PARTTOTAL", parttotal); 486 497 query.bindValue(":LSOURCE", 1); 498 query.bindValue(":AIRDATE", airdate=="" ? "0000" : airdate); 499 query.bindValue(":ORGAIRDATE", originalairdate); 487 500 488 501 if (!query.exec()) 489 502 { -
libs/libmythtv/eit.h
123 123 QDateTime starttime; 124 124 QDateTime endtime; 125 125 QDate originalairdate; 126 QString airdate; // movie year / production year 126 127 DBCredits *credits; 127 128 uint32_t chanid; 128 129 uint16_t partnumber; -
libs/libmythtv/eitfixup.cpp
22 22 m_ukCC("\\[(AD)(,(S)){,1}(,SL){,1}\\]|\\[(S)(,AD){,1}(,SL){,1}\\]|" 23 23 "\\[(SL)(,AD){,1}(,(S)){,1}\\]"), 24 24 m_ukYear("[\\[\\(]([\\d]{4})[\\)\\]]"), 25 m_comHemCountry("^(.+)\\.\\s(.+)\\.\\s(?:([0-9]{2,4})\\.\\s*)?"), 26 m_comHemPEnd("\\.$"), 25 m_comHemCountry("^(\\(.+\\))?\\s?([^ ]+)\\s([^\\.0-9]+)(?:\\sfrån\\s([0-9]{4}))(?:\\smed\\s([^\\.]+))?\\.?"), 27 26 m_comHemDirector("[Rr]egi"), 28 m_comHemActor("[Ss]kådespelare"), 29 m_comHemSub("[.\?] "), 27 m_comHemActor("[Ss]kådespelare|[Ii] rollerna"), 28 m_comHemHost("[Pp]rogramledare"), 29 m_comHemSub("[.\\?\\!] "), 30 30 m_comHemRerun1("[Rr]epris\\sfrån\\s([^\\.]+)(?:\\.|$)"), 31 m_comHemRerun2("([0-9]+)/([0-9]+)(?:\\s-\\s([0-9]{4}))?") 31 m_comHemRerun2("([0-9]+)/([0-9]+)(?:\\s-\\s([0-9]{4}))?"), 32 m_comHemTT("[Tt]ext-[Tt][Vv]"), 33 m_comHemPersSeparator("(, |\\soch\\s)"), 34 m_comHemPersons("\\s?([Rr]egi|[Ss]kådespelare|[Pp]rogramledare|[Ii] rollerna):\\s([^\\.]+)\\."), 35 m_comHemSubEnd("\\s?\\.\\s?$"), 36 m_comHemSeries1("\\s?(?:[dD]el|[eE]pisode)\\s([0-9]+)(?:\\s?(?:/|:|av)\\s?([0-9]+))?\\."), 37 m_comHemSeries2("\\s?-?\\s?([Dd]el\\s+([0-9]+))"), 38 m_comHemTSub("\\s+-\\s+([^\\-]+)") 32 39 { 33 40 } 34 41 … … 370 377 */ 371 378 void EITFixUp::FixComHem(DBEvent &event, bool process_subtitle) const 372 379 { 373 // the format of the subtitle is: 374 // country. category. year. 375 // the year is optional and if the subtitle is 376 // empty the same information is in the Description instead. 377 378 if (event.subtitle.length() == 0 && event.description.length() > 0) 380 // Reverse what EITFixUp::Fix() did 381 if (event.subtitle.isEmpty() && !event.description.isEmpty()) 379 382 { 380 383 event.subtitle = event.description; 381 384 event.description = ""; 382 385 } 383 386 384 // try to find country category and year 385 QRegExp tmpCountry = m_comHemCountry; 386 int pos = tmpCountry.search(event.subtitle); 387 if (pos != -1) 387 // Remove subtitle, it contains the category and we already know that 388 event.subtitle = ""; 389 390 bool isSeries = false; 391 // Try to find episode numbers 392 int pos; 393 QRegExp tmpSeries1 = m_comHemSeries1; 394 QRegExp tmpSeries2 = m_comHemSeries2; 395 if ((pos = tmpSeries2.search(event.title)) != -1) 388 396 { 389 QStringList list = tmpCountry.capturedTexts(); 390 391 // sometimes the category is empty, in that case use the category from 392 // the subtitle. this category is in swedish and all others 393 // are in english 394 if (event.category.length() == 0) 397 QStringList list = tmpSeries2.capturedTexts(); 398 event.partnumber = list[2].toUInt(); 399 event.title = event.title.replace(list[0],""); 400 } 401 else if ((pos = tmpSeries1.search(event.description)) != -1) 402 { 403 QStringList list = tmpSeries1.capturedTexts(); 404 if (!list[1].isEmpty()) 395 405 { 396 event. category = list[2].stripWhiteSpace();406 event.partnumber = list[1].toUInt(); 397 407 } 408 if (!list[2].isEmpty()) 409 { 410 event.parttotal = list[2].toUInt(); 411 } 398 412 399 if (list[3].length() > 0) 413 // Remove the episode numbers, but only if it's not at the begining 414 // of the description (subtitle code might use it) 415 if(pos > 0) 416 event.description = event.description.replace(list[0],""); 417 isSeries = true; 418 } 419 420 // Add partnumber/parttotal to subtitle 421 // This will be overwritten if we find a better subtitle 422 if (event.partnumber > 0) 423 { 424 event.subtitle = QString("Del %1").arg(event.partnumber); 425 if (event.parttotal > 0) 400 426 { 401 bool ok; 402 uint y = list[3].stripWhiteSpace().toUInt(&ok); 403 if (ok) 404 event.originalairdate = QDate(y, 1, 1); 427 event.subtitle += QString(" av %1").arg(event.parttotal); 405 428 } 429 } 406 430 407 // not 100% sure about this one. 408 event.subtitle = ""; 431 // Move subtitle info from title to subtitle 432 QRegExp tmpTSub = m_comHemTSub; 433 if (tmpTSub.search(event.title) != -1) 434 { 435 event.subtitle = tmpTSub.cap(1); 436 event.title = event.title.replace(tmpTSub.cap(0),""); 409 437 } 410 438 439 // No need to continue without a description. 411 440 if (event.description.length() <= 0) 412 441 return; 413 442 414 // everything up to the first 3 spaces is duplicated from title and 415 // subtitle so remove it 416 pos = event.description.find(" "); 443 // Try to find country category, year and possibly other information 444 // from the begining of the description 445 QRegExp tmpCountry = m_comHemCountry; 446 pos = tmpCountry.search(event.description); 417 447 if (pos != -1) 418 448 { 419 event.description = 420 event.description.mid(pos + 3).stripWhiteSpace(); 421 //fprintf(stdout, "EITFixUp::FixStyle4: New: %s\n", 422 //event.description.mid(pos + 3).stripWhiteSpace().ascii()); 423 } 449 QStringList list = tmpCountry.capturedTexts(); 450 QString replacement; 424 451 425 // in the description at this point everything up to the first 4 spaces 426 // in a row is a list of director(s) and actors. 427 // different lists are separated by 3 spaces in a row 428 // end of all lists is when there is 4 spaces in a row 429 bool bDontRemove = false; 430 pos = event.description.find(" "); 431 if (pos != -1) 432 { 433 QStringList lists; 434 lists = QStringList::split(" ", event.description.left(pos)); 435 QStringList::iterator it; 436 for (it = lists.begin(); it != lists.end(); it++) 452 // Original title, usually english title 453 // note: list[1] contains extra () around the text that needs removing 454 if (list[1].length() > 0) 437 455 { 438 (*it).remove(m_comHemPEnd); 439 QStringList list = QStringList::split(": ", *it); 440 if (list.count() != 2) 456 replacement = list[1] + " "; 457 //store it somewhere? 458 } 459 460 // Countr(y|ies) 461 if (list[2].length() > 0) 462 { 463 replacement += list[2] + " "; 464 //store it somewhere? 465 } 466 467 // Category 468 if (list[3].length() > 0) 469 { 470 replacement += list[3] + "."; 471 if(event.category.isEmpty()) 441 472 { 442 // oops, improperly formated list, ignore it 443 //fprintf(stdout,"EITFixUp::FixStyle4:" 444 //"%s is not a properly formated list of persons\n", 445 //(*it).ascii()); 446 bDontRemove = true; 447 continue; 473 event.category = list[3]; 448 474 } 449 475 450 if (list[0].find(m_comHemDirector) !=-1)476 if(list[3].find("serie")!=-1) 451 477 { 452 // director(s) 453 QStringList persons = QStringList::split(", ",list[1]); 454 for (QStringList::const_iterator it2 = persons.begin(); 455 it2 != persons.end(); it2++) 456 { 457 event.AddPerson(DBPerson::kDirector, *it2); 458 } 459 continue; 478 isSeries = true; 460 479 } 480 } 461 481 462 if (list[0].find(m_comHemActor) != -1) 482 // Year 483 if (list[4].length() > 0) 484 { 485 event.airdate = list[4].stripWhiteSpace(); 486 } 487 488 // Actors 489 if (list[5].length() > 0) 490 { 491 QStringList actors; 492 actors=QStringList::split(m_comHemPersSeparator,list[5]); 493 for(QStringList::size_type i=0;i<actors.count();i++) 463 494 { 464 // actor(s) 465 QStringList persons = QStringList::split(", ", list[1]); 466 for (QStringList::const_iterator it2 = persons.begin(); 467 it2 != persons.end(); it2++) 468 { 469 event.AddPerson(DBPerson::kActor, *it2); 470 } 471 continue; 495 event.AddPerson(DBPerson::kActor, actors[i]); 472 496 } 497 } 473 498 474 // unknown type, posibly a new one that 475 // this code shoud be updated to handle 476 VERBOSE(VB_EIT, "EITFixUp::FixComHem: " + 477 QString("%1 is not actor or director") 478 .arg(list[0])); 479 bDontRemove = true; 499 // Remove year and actors. 500 // The reason category is left in the description is because otherwise 501 // the country would look wierd like "Amerikansk. Rest of description." 502 event.description = event.description.replace(list[0],replacement); 503 } 504 505 if (isSeries) 506 event.category_type = kCategorySeries; 507 508 // Look for additional persons in the description 509 QRegExp tmpPersons = m_comHemPersons; 510 while(pos = tmpPersons.search(event.description),pos!=-1) 511 { 512 DBPerson::Role role; 513 QStringList list = tmpPersons.capturedTexts(); 514 515 QRegExp tmpDirector = m_comHemDirector; 516 QRegExp tmpActor = m_comHemActor; 517 QRegExp tmpHost = m_comHemHost; 518 if (tmpDirector.search(list[1])!=-1) 519 { 520 role = DBPerson::kDirector; 480 521 } 481 // remove list of persons from description if 482 // we coud parse it properly 483 if (!bDontRemove) 522 else if(tmpActor.search(list[1])!=-1) 484 523 { 485 event.description = event.description.mid(pos).stripWhiteSpace();524 role = DBPerson::kActor; 486 525 } 487 } 526 else if(tmpHost.search(list[1])!=-1) 527 { 528 role = DBPerson::kHost; 529 } 488 530 489 //fprintf(stdout, "EITFixUp::FixStyle4: Number of persons: %d\n", 490 //event.Credits.count()); 531 QStringList actors; 532 actors = QStringList::split(m_comHemPersSeparator, list[2]); 533 for(QStringList::size_type i=0;i<actors.count();i++) 534 { 535 event.AddPerson(role, actors[i]); 536 } 491 537 492 /* 493 a regexp like this coud be used to get the episode number, shoud be at 494 the begining of the description 495 "^(?:[dD]el|[eE]pisode)\\s([0-9]+)(?:\\s?(?:/|:|av)\\s?([0-9]+))?\\." 496 */ 538 // Remove it 539 event.description=event.description.replace(list[0],""); 540 } 497 541 498 542 // Is this event on a channel we shoud look for a subtitle? 543 // The subtitle is the first sentence in the description, but the 544 // subtitle can't be the only thing in the description and it must be 545 // shorter than 55 characters or we risk picking up the wrong thing. 499 546 if (process_subtitle) 500 547 { 501 548 int pos = event.description.find(m_comHemSub); … … 508 555 } 509 556 } 510 557 558 // Teletext subtitles? 559 int position = event.description.find(m_comHemTT); 560 if (position != -1) 561 { 562 event.flags |= DBEvent::kSubtitled; 563 } 564 511 565 // Try to findout if this is a rerun and if so the date. 512 566 QRegExp tmpRerun1 = m_comHemRerun1; 513 567 if (tmpRerun1.search(event.description) == -1) 514 568 return; 515 569 570 // Rerun from today 516 571 QStringList list = tmpRerun1.capturedTexts(); 517 572 if (list[1] == "i dag") 518 573 { … … 520 575 return; 521 576 } 522 577 578 // Rerun from yesterday afternoon 523 579 if (list[1] == "eftermiddagen") 524 580 { 525 581 event.originalairdate = event.starttime.date().addDays(-1); 526 582 return; 527 583 } 528 584 585 // Rerun with day, month and possibly year specified 529 586 QRegExp tmpRerun2 = m_comHemRerun2; 530 587 if (tmpRerun2.search(list[1]) != -1) 531 588 { … … 546 603 if (date > event.starttime.date()) 547 604 date = date.addYears(-1); 548 605 event.originalairdate = date; 549 //fprintf(stdout, "EITFixUp::FixStyle4: "550 //"OriginalAirDate set to: %s for '%s'\n",551 //event.OriginalAirDate.toString(Qt::ISODate).ascii(),552 //event.description.ascii());553 606 } 554 607 return; 555 608 } 556 // unknown date, posibly only a year.557 //fprintf(stdout,"EITFixUp::FixStyle4: "558 //"unknown rerun date: %s\n",list[1].ascii());559 609 } 560 610 561 611 /** \fn EITFixUp::FixAUStar(DBEvent&) const -
libs/libmythtv/eithelper.cpp
201 201 void EITHelper::AddEIT(const DVBEventInformationTable *eit) 202 202 { 203 203 uint descCompression = (eit->TableID() > 0x80) ? 2 : 1; 204 uint fix = fixup[ eit->OriginalNetworkID() << 16];204 uint fix = fixup[(int)eit->OriginalNetworkID() << 16]; 205 205 fix |= fixup[(((uint64_t)eit->TSID()) << 32) | 206 206 (eit->OriginalNetworkID() << 16)]; 207 fix |= fixup[( eit->OriginalNetworkID() << 16) | eit->ServiceID()];207 fix |= fixup[(((int)eit->OriginalNetworkID()) << 16) | ((int)eit->ServiceID())]; 208 208 fix |= EITFixUp::kFixGenericDVB; 209 209 210 210 uint networkid = eit->OriginalNetworkID(); … … 452 452 { 453 453 // Check to see if we are interseted in this channel 454 454 bool useOnAirGuide = query.value(1).toBool(); 455 return (useOnAirGuide) ? query.value(0).toInt() : -1; 455 return (useOnAirGuide) ? query.value(0).toInt() : -1; 456 456 } 457 457 458 458 return -1; -
libs/libmythtv/eitfixup.h
67 67 const QRegExp m_ukCC; 68 68 const QRegExp m_ukYear; 69 69 const QRegExp m_comHemCountry; 70 const QRegExp m_comHemPEnd;71 70 const QRegExp m_comHemDirector; 72 71 const QRegExp m_comHemActor; 72 const QRegExp m_comHemHost; 73 73 const QRegExp m_comHemSub; 74 74 const QRegExp m_comHemRerun1; 75 75 const QRegExp m_comHemRerun2; 76 const QRegExp m_comHemTT; 77 const QRegExp m_comHemPersSeparator; 78 const QRegExp m_comHemPersons; 79 const QRegExp m_comHemSubEnd; 80 const QRegExp m_comHemSeries1; 81 const QRegExp m_comHemSeries2; 82 const QRegExp m_comHemTSub; 76 83 }; 77 84 78 85 #endif // EITFIXUP_H