//----------------------------------------------------------------------------------------------
void TestFinderController::testNominalCase ()
{
    TestFinderController fixture;

    fixture._finder1.setResults (
                FinderResults () << FinderResult("House", "http", true, 1));
    fixture._finder2.setResults (
                FinderResults() << FinderResult("houseief", "url", true, 15)
                                       << FinderResult("house.S02E07.LOL", "xxx", true, 2));
    //
    fixture._sut.addFinder (&fixture._finder1);
    fixture._sut.addFinder (&fixture._finder2);
    //
    fixture._sut.findNextEpisode (Serie("House", 2, 6));
    //
    QVERIFY2(fixture._sut.episodeIsFound (), "Episode found");
    QVERIFY2(fixture._sut.episodeFoundIsFromTorrent (), "Episode from torrent");
    QVERIFY2(fixture._sut.getEpisodeUrl () == "xxx", "Episode url");
    QVERIFY2(fixture._finder1.getRequest () == "|House S02E07|House 2x07", "Request Finder 1");
    QVERIFY2(fixture._finder2.getRequest () == "|House S02E07|House 2x07", "Request Finder 2");
}
//----------------------------------------------------------------------------------------------
void TestFinderController::testRegExp ()
{
    TestFinderController fixture;
    
    fixture._finder1.setResults (FinderResults () << 
                                 FinderResult("Merlin Season 1-2-3", "http", false, 1));
    //
    fixture._sut.addFinder (&fixture._finder1);
    //
    fixture._sut.findNextEpisode (Serie("Merlin", 2, 2));
    //
    QVERIFY2(!fixture._sut.episodeIsFound (), "Episode not found, the regexp doesnt match");
    
    fixture._finder1.setResults (
                                 FinderResults () << FinderResult("Merlin 2x03", "http", false, 1));
    //
    fixture._sut.findNextEpisode (Serie("Merlin", 2, 2));
    //
    QVERIFY2(fixture._sut.episodeIsFound (), "Episode found, the regexp match");
    QVERIFY2(!fixture._sut.episodeFoundIsFromTorrent (), "Episode found not from torrent");

}
//----------------------------------------------------------------------------------------------
void TestFinderController::testSerieWithSpaces ()
{
    TestFinderController fixture;

    fixture._finder1.setResults (
                FinderResults () << FinderResult("-The-Event-S01-E01", "http", true, 1));
    //
    fixture._sut.addFinder (&fixture._finder1);
    //
    fixture._sut.findNextEpisode (Serie("The Event", 1 , 0));
    //
    QVERIFY2(fixture._sut.episodeIsFound (), "Episode found");
    QVERIFY2(fixture._finder1.getRequest () == "|The Event S01E01|The Event 1x01", "Request Finder 1");
}
Example #4
0
void TestScheduler::testNominalDdl ()
{
    TestScheduler fixture;
    
    fixture._series->addSerie (houseSeason1);
    fixture._series->addSerie (Serie("House", 2, 1, false));
    fixture._finder->setResults (FinderResults () <<
                                 FinderResult("House.S01.E01", "house_ddl_url", false, 10));
    fixture._network->setIsReady (true);
    
    fixture._sut->update ();
    
    QVERIFY2 (fixture._finder->getRequest () == "|House S01E01|House 1x01", "Nominal request");
    QVERIFY2 (fixture._series->at(0).lastEpisode () == 1, "Nominal inc");
    QVERIFY2 (fixture._logger->success ().contains ("Season 1 Episode 1"), "info display");
    QVERIFY2 (fixture._logger->info ().contains ("house_ddl_url"), "url displayed");
    
}
Example #5
0
 void TestScheduler::testNominalTorrent ()
 {
     TestScheduler fixture;

     fixture._series->addSerie (houseSeason1);
     fixture._finder->setResults (FinderResults () <<
                                  FinderResult("House.S01.E01", "house_torrent", true, 10));
     fixture._network->setIsReady (true);

     fixture._sut->update ();

     QVERIFY2 (fixture._finder->getRequest () == "|House S01E01|House 1x01", "Nominal request");
     QVERIFY2 (fixture._network->url () == "house_torrent", "Nominal url");
     QVERIFY2 (fixture._series->at(0).lastEpisode () == 1, "Nominal inc");
     QVERIFY2 (fixture._logger->success ().contains ("Season 1 Episode 1"), "info display");
     QVERIFY2 (QFile::exists (fixture._serieDownloader->_absoluteFileName),
               "Torrent downloaded");
}
Example #6
0
FinderResult Finder::find() {
    bool done = false;
    int skipRows = 3;
    int stateCount[5] = {0};
    int currentState = 0;
    for(int row = skipRows - 1; row < image.rows; row += skipRows)
    {
        stateCount[0] = 0;
        stateCount[1] = 0;
        stateCount[2] = 0;
        stateCount[3] = 0;
        stateCount[4] = 0;
        currentState = 0;
//        uchar* ptr = image.ptr<uchar>(row);
        for(int col=0; col < image.cols; col++)
        {
            Point p = Point(col, row);
            if(image.at<uchar>(p) < 128)
            {
                // We're at a black pixel
                if((currentState & 0x1)==1)
                {
                    // We were counting white pixels
                    // So change the state now
                    
                    // W->B transition
                    currentState++;
                }
                
                // Works for boths W->B and B->B
                stateCount[currentState]++;
            }
            else
            {
                // We got to a white pixel...
                if((currentState & 0x1)==1)
                {
                    // W->W change
                    stateCount[currentState]++;
                }
                else
                {
                    // ...but, we were counting black pixels
                    if(currentState==4)
                    {
                        // We found the 'white' area AFTER the finder patter
                        // Do processing for it here
                        if(checkRatio(stateCount))
                        {
                            // This is where we do some more checks
                            bool confirmed = handlePossibleCenter(stateCount, row, col);
                            if(confirmed) {
                                skipRows = 2;
                                if(hasSkipped) {
                                    done = haveMultiplyConfirmedCenters();
                                }
                                else {
                                    int rowsToSkip = getRowSkip();
                                    if(rowsToSkip > stateCount[2]) {
                                        row += rowsToSkip - stateCount[2] - skipRows;
                                        col = image.cols - 1;
                                    }
                                }
                            }
                            else {
                                stateCount[0] = stateCount[2];
                                stateCount[1] = stateCount[3];
                                stateCount[2] = stateCount[4];
                                stateCount[3] = 1;
                                stateCount[4] = 0;
                                currentState = 3;
                                continue;
                            }
                            
                            // Reset all counts and continue looking for more
                            // finder patterns in the current row
                            currentState = 0;
                            stateCount[0] = 0;
                            stateCount[1] = 0;
                            stateCount[2] = 0;
                            stateCount[3] = 0;
                            stateCount[4] = 0;
                            
                        }
                        else
                        {
                            currentState = 3;
                            stateCount[0] = stateCount[2];
                            stateCount[1] = stateCount[3];
                            stateCount[2] = stateCount[4];
                            stateCount[3] = 1;
                            stateCount[4] = 0;
                            continue;
                        }
                        currentState = 0;
                        stateCount[0] = 0;
                        stateCount[1] = 0;
                        stateCount[2] = 0;
                        stateCount[3] = 0;
                        stateCount[4] = 0;
                    }
                    else
                    {
                        // We still haven't go 'out' of the finder pattern yet
                        // So increment the state
                        // B->W transition
                        currentState++;
                        stateCount[currentState]++;
                    }
                }
            }
        }
    }
//    vector<FinderPoint> best = selectBestPattern();
    vector<FinderPoint> best = orderBestPatterns();
    FinderResult result = FinderResult(best);
    return result;
}