Ticket #12291: videoselector.diff

File videoselector.diff, 2.1 KB (added by paulh, 12 years ago)

possible fix (untested)

  • mythplugins/mytharchive/mytharchive/videoselector.cpp

    diff --git a/mythplugins/mytharchive/mytharchive/videoselector.cpp b/mythplugins/mytharchive/mytharchive/videoselector.cpp
    index ab5f700..73e0f50 100644
    a b vector<VideoInfo *> *VideoSelector::getVideoListFromDB(void)  
    457457            info->plot = query.value(2).toString();
    458458            info->size = 0; //query.value(3).toInt();
    459459            QString host = query.value(11).toString();
    460             info->filename = host.isEmpty() ? filename
    461                 : generate_file_url("Videos", host, filename);
     460
     461            // try to find the file locally
     462            if (host.isEmpty())
     463            {
     464                // must be already be a local filename?
     465                info->filename = filename;
     466            }
     467            else
     468            {
     469                // if the file is on this host then we should be able to find it locally
     470                if (host == gCoreContext->GetHostName())
     471                {
     472                    StorageGroup videoGroup("Videos", gCoreContext->GetHostName(), false);
     473                    info->filename = videoGroup.FindFile(filename);
     474
     475                    // sanity check the file exists
     476                    if (!QFile::exists(info->filename))
     477                    {
     478                        LOG(VB_GENERAL, LOG_ERR,
     479                            QString("VideoSelector: Failed to find local file '%1'").arg(info->filename));
     480                        info->filename.clear();
     481                    }
     482                }
     483
     484                if (info->filename.isEmpty())
     485                {
     486                    // file must not be local or doesn't exist
     487                    info->filename = generate_file_url("Videos", host, filename);
     488                }
     489            }
     490
     491            LOG(VB_GENERAL, LOG_INFO,
     492                QString("VideoSelector: found file '%1'").arg(info->filename));
     493
    462494            info->coverfile = query.value(5).toString();
    463495            info->category = categoryMap[query.value(6).toInt()];
    464496            info->parentalLevel = query.value(7).toInt();