Ticket #713: perchanneloffset_jv_v1.diff

File perchanneloffset_jv_v1.diff, 9.8 KB (added by Joe Votour <joevph@…>, 14 years ago)

Patch against SVN9270 with changes by cpinkham

  • libs/libmythtv/channelsettings.cpp

    diff -Naur mythtv_unpatched/libs/libmythtv/channelsettings.cpp mythtv/libs/libmythtv/channelsettings.cpp
    old new  
    8282    };
    8383};
    8484
     85class TimeOffset: public SpinBoxSetting, public CSetting {
     86public:
     87    TimeOffset(const ChannelID& id):
     88        SpinBoxSetting(-1440, 1440, 1), CSetting(id, "tmoffset") {
     89        setLabel(QObject::tr("DataDirect") + " " + QObject::tr("Time Offset"));
     90        setHelpText(QObject::tr("Offset (in minutes) to apply to the program "
     91                    "guide data during import.  This can be used when the "
     92                    "listings for a particular channel are in a different "
     93                    "time zone.") + " " +
     94                    QObject::tr("(Works for DataDirect listings only.)"));
     95    };
     96};
     97
    8598class Rank: public SpinBoxSetting, public CSetting {
    8699public:
    87100    Rank(const ChannelID& id):
     
    284297    connect(source,SIGNAL(valueChanged(const QString&)),this,SLOT(sourceChanged(const QString&)));
    285298#else
    286299    addChild(new XmltvID(id));
     300    addChild(new TimeOffset(id));
    287301#endif
    288302};
    289303
     
    347361    addChild(new Colour(id));
    348362    addChild(new Hue(id));
    349363};
     364
     365/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • libs/libmythtv/dbcheck.cpp

    diff -Naur mythtv_unpatched/libs/libmythtv/dbcheck.cpp mythtv/libs/libmythtv/dbcheck.cpp
    old new  
    1010#include "mythdbcon.h"
    1111
    1212/// This is the DB schema version expected by the running MythTV instance.
    13 const QString currentDatabaseVersion = "1129";
     13const QString currentDatabaseVersion = "1130";
    1414
    1515static bool UpdateDBVersionNumber(const QString &newnumber);
    1616static bool performActualUpdate(const QString updates[], QString version,
     
    240240The 'xmltvid' field is used to identify this channel to the listings
    241241provider.
    242242
     243The 'tmoffset' field is used to apply an offset (in minutes) from the listings
     244provided by the provider to a new time in the MythTV program guide database.
     245This is very handy when the listings provider has listings which are offset
     246by a few hours on individual channels with the rest of them being correct.
     247
    243248The 'recpriority' field is used tell the scheduler from which of two
    244249otherwise equivalent programs on two different channels should be
    245250prefered, a higher number means this channel is more preferred.
     
    21122117            return false;
    21132118    }
    21142119
     2120    if (dbver == "1129")
     2121    {
     2122        const QString updates[] = {
     2123"ALTER TABLE channel ADD COLUMN tmoffset INT NOT NULL default '0';",
     2124""
     2125};
     2126
     2127        if (!performActualUpdate(updates, "1130", dbver))
     2128            return false;
     2129    }
     2130
    21152131//"ALTER TABLE capturecard DROP COLUMN dvb_recordts;" in 0.21
    21162132//"ALTER TABLE capturecard DROP COLUMN dvb_hw_decoder;" in 0.21
    21172133
  • programs/mythfilldatabase/filldata.cpp

    diff -Naur mythtv_unpatched/programs/mythfilldatabase/filldata.cpp mythtv/programs/mythfilldatabase/filldata.cpp
    old new  
    225225
    226226void clearDataByChannel(int chanid, QDateTime from, QDateTime to)
    227227{
     228    int secs;
     229    QDateTime newFrom, newTo;
     230
    228231    MSqlQuery query(MSqlQuery::InitCon());
    229232
     233    query.prepare("SELECT tmoffset FROM channel where chanid = :CHANID ;");
     234    query.bindValue(":CHANID", chanid);
     235    query.exec();
     236    if (!query.isActive() || query.size() != 1)
     237    {
     238        MythContext::DBError("clearDataByChannel", query);
     239        return;
     240    }
     241    query.next();
     242    secs = query.value(0).toInt();
     243
     244    secs *= 60;
     245    newFrom = from.addSecs(secs);
     246    newTo = to.addSecs(secs);
     247
    230248    query.prepare("DELETE FROM program "
    231249                  "WHERE starttime >= :FROM AND starttime < :TO "
    232250                  "AND chanid = :CHANID ;");
    233     query.bindValue(":FROM", from);
    234     query.bindValue(":TO", to);
     251    query.bindValue(":FROM", newFrom);
     252    query.bindValue(":TO", newTo);
    235253    query.bindValue(":CHANID", chanid);
    236254    query.exec();
    237255
    238256    query.prepare("DELETE FROM programrating "
    239257                  "WHERE starttime >= :FROM AND starttime < :TO "
    240258                  "AND chanid = :CHANID ;");
    241     query.bindValue(":FROM", from);
    242     query.bindValue(":TO", to);
     259    query.bindValue(":FROM", newFrom);
     260    query.bindValue(":TO", newTo);
    243261    query.bindValue(":CHANID", chanid);
    244262    query.exec();
    245263
    246264    query.prepare("DELETE FROM credits "
    247265                  "WHERE starttime >= :FROM AND starttime < :TO "
    248266                  "AND chanid = :CHANID ;");
    249     query.bindValue(":FROM", from);
    250     query.bindValue(":TO", to);
     267    query.bindValue(":FROM", newFrom);
     268    query.bindValue(":TO", newTo);
    251269    query.bindValue(":CHANID", chanid);
    252270    query.exec();
    253271
    254272    query.prepare("DELETE FROM programgenres "
    255273                  "WHERE starttime >= :FROM AND starttime < :TO "
    256274                  "AND chanid = :CHANID ;");
    257     query.bindValue(":FROM", from);
    258     query.bindValue(":TO", to);
     275    query.bindValue(":FROM", newFrom);
     276    query.bindValue(":TO", newTo);
    259277    query.bindValue(":CHANID", chanid);
    260278    query.exec();
    261279}
     
    9881006                    "hdtv, closecaptioned, partnumber, parttotal, seriesid, "
    9891007                    "originalairdate, colorcode, syndicatedepisodenumber, "
    9901008                    "programid) "
    991                     "SELECT chanid, starttime, endtime, "
     1009                    "SELECT dd_v_program.chanid, "
     1010                    "DATE_ADD(starttime, INTERVAL channel.tmoffset MINUTE), "
     1011                    "DATE_ADD(endtime, INTERVAL channel.tmoffset MINUTE), "
    9921012                    "title, subtitle, description, "
    9931013                    "showtype, dd_genre.class, category_type, "
    9941014                    "airdate, stars, previouslyshown, stereo, subtitled, "
    9951015                    "hdtv, closecaptioned, partnumber, parttotal, seriesid, "
    9961016                    "originalairdate, colorcode, syndicatedepisodenumber, "
    997                     "dd_v_program.programid FROM dd_v_program "
     1017                    "dd_v_program.programid FROM dd_v_program, channel "
    9981018                    "LEFT JOIN dd_genre ON ("
    9991019                    "dd_v_program.programid = dd_genre.programid AND "
    1000                     "dd_genre.relevance = '0');"))
     1020                    "dd_genre.relevance = '0') "
     1021                    "WHERE dd_v_program.chanid = channel.chanid;"))
    10011022        MythContext::DBError("Inserting into program table", query);
    10021023
    10031024    //cerr << "Finished adding rows to main program table...\n";
    10041025    //cerr << "Adding program ratings...\n";
    10051026
    10061027    if (!query.exec("INSERT IGNORE INTO programrating (chanid, starttime, "
    1007                     "system, rating) SELECT chanid, starttime, 'MPAA', "
    1008                     "mpaarating FROM dd_v_program WHERE mpaarating != '';"))
     1028                    "system, rating) SELECT dd_v_program.chanid, "
     1029                    "DATE_ADD(starttime, INTERVAL channel.tmoffset MINUTE), "
     1030                    " 'MPAA', "
     1031                    "mpaarating FROM dd_v_program, channel WHERE "
     1032                    "mpaarating != '' AND dd_v_program.chanid = "
     1033                    "channel.chanid"))
    10091034        MythContext::DBError("Inserting into programrating table", query);
    10101035
    10111036    if (!query.exec("INSERT IGNORE INTO programrating (chanid, starttime, "
    1012                     "system, rating) SELECT chanid, starttime, 'VCHIP', "
    1013                     "tvrating FROM dd_v_program WHERE tvrating != '';"))
     1037                    "system, rating) SELECT dd_v_program.chanid, "
     1038                    "DATE_ADD(starttime, INTERVAL channel.tmoffset MINUTE), "
     1039                    "'VCHIP', "
     1040                    "tvrating FROM dd_v_program, channel WHERE tvrating != ''"
     1041                    " AND dd_v_program.chanid = channel.chanid"))
    10141042        MythContext::DBError("Inserting into programrating table", query);
    10151043
    10161044    //cerr << "Finished adding program ratings...\n";
     
    10241052    //cerr << "Adding credits entries from production crew list...\n";
    10251053
    10261054    if (!query.exec("INSERT IGNORE INTO credits (chanid, starttime, person, "
    1027                     "role) SELECT chanid, starttime, person, role "
    1028                     "FROM dd_productioncrew, dd_v_program, people "
     1055                    "role) SELECT dd_v_program.chanid, "
     1056                    "DATE_ADD(starttime, INTERVAL channel.tmoffset MINUTE), "
     1057                    "person, role "
     1058                    "FROM dd_productioncrew, dd_v_program, channel, people "
    10291059                    "WHERE "
    10301060                    "((dd_productioncrew.programid = dd_v_program.programid) "
    1031                     "AND (dd_productioncrew.fullname = people.name));"))
     1061                    "AND (dd_productioncrew.fullname = people.name)) "
     1062                    "AND dd_v_program.chanid = channel.chanid;"))
    10321063        MythContext::DBError("Inserting into credits table", query);
    10331064
    10341065    //cerr << "Finished inserting credits...\n";
    10351066    //cerr << "Adding genres...\n";
    10361067
    10371068    if (!query.exec("INSERT IGNORE INTO programgenres (chanid, starttime, "
    1038                     "relevance, genre) SELECT chanid, starttime, "
    1039                     "relevance, class FROM dd_v_program, dd_genre "
    1040                     "WHERE (dd_v_program.programid = dd_genre.programid);"))
     1069                    "relevance, genre) SELECT dd_v_program.chanid, "
     1070                    "DATE_ADD(starttime, INTERVAL channel.tmoffset MINUTE), "
     1071                    "relevance, class FROM dd_v_program, dd_genre, channel "
     1072                    "WHERE (dd_v_program.programid = dd_genre.programid) "
     1073                    "AND dd_v_program.chanid = channel.chanid"))
    10411074        MythContext::DBError("Inserting into programgenres table",query);
    10421075
    10431076    //cerr << "Done...\n";