Beispiel #1
0
DTC::VideoMetadataInfoList* Video::GetVideoList( bool bDescending,
                                                 int nStartIndex,
                                                 int nCount       )
{
    VideoMetadataListManager::metadata_list videolist;
    QString sql = "ORDER BY intid";
    if (bDescending)
        sql += " DESC";
    VideoMetadataListManager::loadAllFromDatabase(videolist, sql);

    std::vector<VideoMetadataListManager::VideoMetadataPtr> videos(videolist.begin(), videolist.end());

    // ----------------------------------------------------------------------
    // Build Response
    // ----------------------------------------------------------------------

    DTC::VideoMetadataInfoList *pVideoMetadataInfos = new DTC::VideoMetadataInfoList();

    nStartIndex   = min( nStartIndex, (int)videos.size() );
    nCount        = (nCount > 0) ? min( nCount, (int)videos.size() ) : videos.size();
    int nEndIndex = min((nStartIndex + nCount), (int)videos.size() );

    for( int n = nStartIndex; n < nEndIndex; n++ )
    {
        DTC::VideoMetadataInfo *pVideoMetadataInfo = pVideoMetadataInfos->AddNewVideoMetadataInfo();

        VideoMetadataListManager::VideoMetadataPtr metadata = videos[n];

        if (metadata)
            FillVideoMetadataInfo ( pVideoMetadataInfo, metadata, true );
    }

    int curPage = 0, totalPages = 0;
    if (nCount == 0)
        totalPages = 1;
    else
        totalPages = (int)ceil((float)videos.size() / nCount);

    if (totalPages == 1)
        curPage = 1;
    else
    {
        curPage = (int)ceil((float)nStartIndex / nCount) + 1;
    }

    pVideoMetadataInfos->setStartIndex    ( nStartIndex     );
    pVideoMetadataInfos->setCount         ( nCount          );
    pVideoMetadataInfos->setCurrentPage   ( curPage         );
    pVideoMetadataInfos->setTotalPages    ( totalPages      );
    pVideoMetadataInfos->setTotalAvailable( videos.size()   );
    pVideoMetadataInfos->setAsOf          ( QDateTime::currentDateTime() );
    pVideoMetadataInfos->setVersion       ( MYTH_BINARY_VERSION );
    pVideoMetadataInfos->setProtoVer      ( MYTH_PROTO_VERSION  );

    return pVideoMetadataInfos;
}
Beispiel #2
0
DTC::VideoMetadataInfoList* Video::GetVideos( bool bDescending,
                                              int nStartIndex,
                                              int nCount       )
{
    VideoMetadataListManager::metadata_list videolist;
    VideoMetadataListManager::loadAllFromDatabase(videolist);

    std::vector<VideoMetadataListManager::VideoMetadataPtr> videos(videolist.begin(), videolist.end());

    // ----------------------------------------------------------------------
    // Build Response
    // ----------------------------------------------------------------------

    DTC::VideoMetadataInfoList *pVideoMetadataInfos = new DTC::VideoMetadataInfoList();

    nStartIndex   = min( nStartIndex, (int)videos.size() );
    nCount        = (nCount > 0) ? min( nCount, (int)videos.size() ) : videos.size();
    int nEndIndex = min((nStartIndex + nCount), (int)videos.size() );

    for( int n = nStartIndex; n < nEndIndex; n++ )
    {
        DTC::VideoMetadataInfo *pVideoMetadataInfo = pVideoMetadataInfos->AddNewVideoMetadataInfo();

        VideoMetadataListManager::VideoMetadataPtr metadata = videos[n];

        if (metadata)
        {
            pVideoMetadataInfo->setId(metadata->GetID());
            pVideoMetadataInfo->setTitle(metadata->GetTitle());
            pVideoMetadataInfo->setSubTitle(metadata->GetSubtitle());
            pVideoMetadataInfo->setTagline(metadata->GetTagline());
            pVideoMetadataInfo->setDirector(metadata->GetDirector());
            pVideoMetadataInfo->setStudio(metadata->GetStudio());
            pVideoMetadataInfo->setDescription(metadata->GetPlot());
            pVideoMetadataInfo->setCertification(metadata->GetRating());
            pVideoMetadataInfo->setInetRef(metadata->GetInetRef());
            pVideoMetadataInfo->setHomePage(metadata->GetHomepage());
            pVideoMetadataInfo->setReleaseDate(QDateTime(metadata->GetReleaseDate()));
            pVideoMetadataInfo->setAddDate(QDateTime(metadata->GetInsertdate()));
            pVideoMetadataInfo->setUserRating(metadata->GetUserRating());
            pVideoMetadataInfo->setLength(metadata->GetLength());
            pVideoMetadataInfo->setSeason(metadata->GetSeason());
            pVideoMetadataInfo->setEpisode(metadata->GetEpisode());
            pVideoMetadataInfo->setParentalLevel(metadata->GetShowLevel());
            pVideoMetadataInfo->setVisible(metadata->GetBrowse());
            pVideoMetadataInfo->setWatched(metadata->GetWatched());
            pVideoMetadataInfo->setProcessed(metadata->GetProcessed());
            pVideoMetadataInfo->setFileName(metadata->GetFilename());
            pVideoMetadataInfo->setHash(metadata->GetHash());
            pVideoMetadataInfo->setHost(metadata->GetHost());
            pVideoMetadataInfo->setCoverart(metadata->GetCoverFile());
            pVideoMetadataInfo->setFanart(metadata->GetFanart());
            pVideoMetadataInfo->setBanner(metadata->GetBanner());
            pVideoMetadataInfo->setScreenshot(metadata->GetScreenshot());
            pVideoMetadataInfo->setTrailer(metadata->GetTrailer());
        }
    }

    int curPage = 0, totalPages = 0;
    if (nCount == 0)
        totalPages = 1;
    else
        totalPages = (int)ceil((float)videos.size() / nCount);

    if (totalPages == 1)
        curPage = 1;
    else
    {
        curPage = (int)ceil((float)nStartIndex / nCount) + 1;
    }

    pVideoMetadataInfos->setStartIndex    ( nStartIndex     );
    pVideoMetadataInfos->setCount         ( nCount          );
    pVideoMetadataInfos->setCurrentPage   ( curPage         );
    pVideoMetadataInfos->setTotalPages    ( totalPages      );
    pVideoMetadataInfos->setTotalAvailable( videos.size()   );
    pVideoMetadataInfos->setAsOf          ( QDateTime::currentDateTime() );
    pVideoMetadataInfos->setVersion       ( MYTH_BINARY_VERSION );
    pVideoMetadataInfos->setProtoVer      ( MYTH_PROTO_VERSION  );

    return pVideoMetadataInfos;
}