mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
yt cache: accessing a download that's still in progress is fine.
This commit is contained in:
@@ -65,11 +65,25 @@ std::string cYTCache::getName(MI_MOVIE_INFO *mi, std::string ext)
|
|||||||
|
|
||||||
bool cYTCache::useCachedCopy(MI_MOVIE_INFO *mi)
|
bool cYTCache::useCachedCopy(MI_MOVIE_INFO *mi)
|
||||||
{
|
{
|
||||||
std::string cache = getName(mi);
|
std::string file = getName(mi);
|
||||||
if (!access(cache.c_str(), R_OK)) {
|
if (access(file.c_str(), R_OK))
|
||||||
mi->file.Url = cache;
|
return false;
|
||||||
|
std::string xml = getName(mi, "xml");
|
||||||
|
if (!access(xml.c_str(), R_OK)) {
|
||||||
|
mi->file.Url = file;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||||
|
if (pending.empty())
|
||||||
|
return false;
|
||||||
|
MI_MOVIE_INFO m = pending.front();
|
||||||
|
if (compareMovieInfo(&m, mi)) {
|
||||||
|
mi->file.Url = file;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,9 +98,8 @@ int cYTCache::curlProgress(void *clientp, double /*dltotal*/, double /*dlnow*/,
|
|||||||
bool cYTCache::download(MI_MOVIE_INFO *mi)
|
bool cYTCache::download(MI_MOVIE_INFO *mi)
|
||||||
{
|
{
|
||||||
std::string file = getName(mi);
|
std::string file = getName(mi);
|
||||||
std::string tmpfile = file + ".tmp";
|
std::string xml = getName(mi, "xml");
|
||||||
|
if (!access(file.c_str(), R_OK) && !access(file.c_str(), R_OK))
|
||||||
if (!access(file.c_str(), R_OK) || !access(tmpfile.c_str(), R_OK))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
FILE * fp = fopen(file.c_str(), "wb");
|
FILE * fp = fopen(file.c_str(), "wb");
|
||||||
@@ -120,14 +133,12 @@ bool cYTCache::download(MI_MOVIE_INFO *mi)
|
|||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
fprintf(stderr, "curl error: %s\n", cerror);
|
fprintf(stderr, "curl error: %s\n", cerror);
|
||||||
unlink(tmpfile.c_str());
|
unlink(file.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rename (tmpfile.c_str(), file.c_str());
|
|
||||||
CMovieInfo cMovieInfo;
|
CMovieInfo cMovieInfo;
|
||||||
CFile File;
|
CFile File;
|
||||||
File.Name = getName(mi, "xml");
|
File.Name = xml;
|
||||||
cMovieInfo.convertTs2XmlName(&File.Name);
|
|
||||||
cMovieInfo.saveMovieInfo(*mi, &File);
|
cMovieInfo.saveMovieInfo(*mi, &File);
|
||||||
std::string thumbnail_dst = getName(mi, "jpg");
|
std::string thumbnail_dst = getName(mi, "jpg");
|
||||||
std::string thumbnail_src = "/tmp/ytparser/" + mi->ytid + ".jpg";
|
std::string thumbnail_src = "/tmp/ytparser/" + mi->ytid + ".jpg";
|
||||||
|
Reference in New Issue
Block a user