Ticket #10747: mythtv.airdate.patch
File mythtv.airdate.patch, 8.2 KB (added by , 12 years ago) |
---|
-
mythtv/programs/mythbackend/housekeeper.cpp
diff --git a/mythtv/programs/mythbackend/housekeeper.cpp b/mythtv/programs/mythbackend/housekeeper.cpp index 29ab7ea..9cfbcc2 100644
a b void HouseKeeper::CleanupProgramListings(void) 668 668 // Keep as many days of listings data as we keep matching, non-recorded 669 669 // oldrecorded entries to allow for easier post-mortem analysis 670 670 int offset = gCoreContext->GetNumSetting( "CleanOldRecorded", 10); 671 // Also make sure to keep enough data so that we can flag the original 672 // air date, for when that isn't included in guide data 673 int newEpiWindow = gCoreContext->GetNumSetting( "NewEpisodeWindow", 14); 674 if (newEpiWindow > offset) 675 offset = newEpiWindow; 671 676 672 677 query.prepare("DELETE FROM oldprogram WHERE airdate < " 673 678 "DATE_SUB(CURRENT_DATE, INTERVAL 320 DAY);"); -
mythtv/programs/mythfilldatabase/main.cpp
diff --git a/mythtv/programs/mythfilldatabase/main.cpp b/mythtv/programs/mythfilldatabase/main.cpp index 57d4709..4c013ee 100644
a b int main(int argc, char *argv[]) 607 607 LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found)); 608 608 } 609 609 610 if (mark_repeats)611 {612 LOG(VB_GENERAL, LOG_INFO, "Marking repeats.");613 614 int newEpiWindow = gCoreContext->GetNumSetting( "NewEpisodeWindow", 14);615 616 MSqlQuery query(MSqlQuery::InitCon());617 query.prepare("UPDATE program SET previouslyshown = 1 "618 "WHERE previouslyshown = 0 "619 "AND originalairdate is not null "620 "AND (to_days(starttime) - to_days(originalairdate)) "621 " > :NEWWINDOW;");622 query.bindValue(":NEWWINDOW", newEpiWindow);623 624 if (query.exec())625 LOG(VB_GENERAL, LOG_INFO,626 QString(" Found %1").arg(query.numRowsAffected()));627 628 LOG(VB_GENERAL, LOG_INFO, "Unmarking new episode rebroadcast repeats.");629 query.prepare("UPDATE program SET previouslyshown = 0 "630 "WHERE previouslyshown = 1 "631 "AND originalairdate is not null "632 "AND (to_days(starttime) - to_days(originalairdate)) "633 " <= :NEWWINDOW;");634 query.bindValue(":NEWWINDOW", newEpiWindow);635 636 if (query.exec())637 LOG(VB_GENERAL, LOG_INFO,638 QString(" Found %1").arg(query.numRowsAffected()));639 }640 641 610 // Mark first and last showings 642 611 643 612 if (grab_data) … … int main(int argc, char *argv[]) 647 616 if (!updt.exec()) 648 617 MythDB::DBError("Clearing first and last showings", updt); 649 618 619 MSqlQuery updtAirdate(MSqlQuery::InitCon()); 620 650 621 LOG(VB_GENERAL, LOG_INFO, "Marking episode first showings."); 651 622 652 623 MSqlQuery query(MSqlQuery::InitCon()); 653 query.prepare("SELECT MIN(starttime),programid FROM program " 624 query.prepare("SELECT MIN(starttime),programid,previouslyshown " 625 "FROM program " 654 626 "WHERE programid > '' GROUP BY programid;"); 655 627 if (query.exec()) 656 628 { 657 629 updt.prepare("UPDATE program set first = 1 " 658 630 "WHERE starttime = :STARTTIME " 659 631 " AND programid = :PROGRAMID;"); 632 updtAirdate.prepare("UPDATE program " 633 " SET originalairdate = :ORIGINALAIRDATE " 634 "WHERE originalairdate IS NULL " 635 " AND first = 0 " 636 " AND previouslyshown = 1 " 637 " AND programid = :PROGRAMID;"); 660 638 while(query.next()) 661 639 { 662 640 updt.bindValue(":STARTTIME", query.value(0).toDateTime()); 663 641 updt.bindValue(":PROGRAMID", query.value(1).toString()); 664 642 if (!updt.exec()) 665 643 MythDB::DBError("Marking first showings by id", updt); 644 // If we have the first showing, then we know the 645 // originalairdate for any repeats. Make sure to 646 // not override anything actually given in the source data 647 if (!query.value(2).toBool()) { 648 updtAirdate.bindValue(":ORIGINALAIRDATE", query.value(0).toDate()); 649 updtAirdate.bindValue(":PROGRAMID", query.value(1).toString()); 650 if (!updtAirdate.exec()) 651 MythDB::DBError("Marking originalairdate by id", updtAirdate); 652 } 666 653 } 667 654 } 668 655 int found = query.size(); 669 656 query.prepare("SELECT MIN(starttime),title,subtitle," 670 " LEFT(description, 1024) AS partdesc " 657 " LEFT(description, 1024) AS partdesc," 658 " previouslyshown " 671 659 "FROM program WHERE programid = '' " 672 660 "GROUP BY title,subtitle,partdesc;"); 673 661 if (query.exec()) … … int main(int argc, char *argv[]) 677 665 " AND title = :TITLE " 678 666 " AND subtitle = :SUBTITLE " 679 667 " AND LEFT(description, 1024) = :PARTDESC"); 668 updtAirdate.prepare("UPDATE program " 669 " SET originalairdate = :ORIGINALAIRDATE " 670 "WHERE originalairdate IS NULL " 671 " AND first = 0 " 672 " AND previouslyshown = 1 " 673 " AND title = :TITLE " 674 " AND subtitle = :SUBTITLE " 675 " AND LEFT(description, 1024) = :PARTDESC"); 680 676 while(query.next()) 681 677 { 682 678 updt.bindValue(":STARTTIME", query.value(0).toDateTime()); … … int main(int argc, char *argv[]) 685 681 updt.bindValue(":PARTDESC", query.value(3).toString()); 686 682 if (!updt.exec()) 687 683 MythDB::DBError("Marking first showings", updt); 684 if (!query.value(4).toBool()) { 685 updtAirdate.bindValue(":ORIGINALAIRDATE", query.value(0).toDate()); 686 updtAirdate.bindValue(":TITLE", query.value(1).toString()); 687 updtAirdate.bindValue(":SUBTITLE", query.value(2).toString()); 688 updtAirdate.bindValue(":PARTDESC", query.value(3).toString()); 689 if (!updtAirdate.exec()) 690 MythDB::DBError("Marking original airdate", updt); 691 } 688 692 } 689 693 } 690 694 found += query.size(); … … int main(int argc, char *argv[]) 732 736 LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found)); 733 737 } 734 738 739 if (mark_repeats) 740 { 741 LOG(VB_GENERAL, LOG_INFO, "Marking repeats."); 742 743 int newEpiWindow = gCoreContext->GetNumSetting( "NewEpisodeWindow", 14); 744 745 MSqlQuery query(MSqlQuery::InitCon()); 746 query.prepare("UPDATE program SET previouslyshown = 1 " 747 "WHERE previouslyshown = 0 " 748 "AND originalairdate is not null " 749 "AND (to_days(starttime) - to_days(originalairdate)) " 750 " > :NEWWINDOW;"); 751 query.bindValue(":NEWWINDOW", newEpiWindow); 752 753 if (query.exec()) 754 LOG(VB_GENERAL, LOG_INFO, 755 QString(" Found %1").arg(query.numRowsAffected())); 756 757 LOG(VB_GENERAL, LOG_INFO, "Unmarking new episode rebroadcast repeats."); 758 query.prepare("UPDATE program SET previouslyshown = 0 " 759 "WHERE previouslyshown = 1 " 760 "AND originalairdate is not null " 761 "AND (to_days(starttime) - to_days(originalairdate)) " 762 " <= :NEWWINDOW;"); 763 query.bindValue(":NEWWINDOW", newEpiWindow); 764 765 if (query.exec()) 766 LOG(VB_GENERAL, LOG_INFO, 767 QString(" Found %1").arg(query.numRowsAffected())); 768 } 769 735 770 if (1) // limit MSqlQuery's lifetime 736 771 { 737 772 MSqlQuery query(MSqlQuery::InitCon());