mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 17:31:11 +02:00
system/ytcache: add progress data
Conflicts:
src/gui/moviebrowser.cpp
Origin commit data
------------------
Branch: ni/coolstream
Commit: 050138c107
Author: martii <m4rtii@gmx.de>
Date: 2013-11-16 (Sat, 16 Nov 2013)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -3815,7 +3815,9 @@ void CMovieBrowser::refreshYTMenu()
|
|||||||
yt_menue->removeItem(item_id);
|
yt_menue->removeItem(item_id);
|
||||||
}
|
}
|
||||||
MI_MOVIE_INFO::miSource source = (show_mode == MB_SHOW_YT) ? MI_MOVIE_INFO::YT : MI_MOVIE_INFO::NK;
|
MI_MOVIE_INFO::miSource source = (show_mode == MB_SHOW_YT) ? MI_MOVIE_INFO::YT : MI_MOVIE_INFO::NK;
|
||||||
yt_pending = cYTCache::getInstance()->getPending(source);
|
double dltotal, dlnow;
|
||||||
|
time_t dlstart;
|
||||||
|
yt_pending = cYTCache::getInstance()->getPending(source, &dltotal, &dlnow, &dlstart);
|
||||||
yt_completed = cYTCache::getInstance()->getCompleted(source);
|
yt_completed = cYTCache::getInstance()->getCompleted(source);
|
||||||
yt_failed = cYTCache::getInstance()->getFailed(source);
|
yt_failed = cYTCache::getInstance()->getFailed(source);
|
||||||
|
|
||||||
@@ -3830,10 +3832,17 @@ void CMovieBrowser::refreshYTMenu()
|
|||||||
yt_menue->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MOVIEBROWSER_YT_PENDING));
|
yt_menue->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MOVIEBROWSER_YT_PENDING));
|
||||||
yt_menue->addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_CANCEL, true, NULL, ytcache_selector, "cancel_all"));
|
yt_menue->addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_CANCEL, true, NULL, ytcache_selector, "cancel_all"));
|
||||||
yt_menue->addItem(GenericMenuSeparator);
|
yt_menue->addItem(GenericMenuSeparator);
|
||||||
|
std::string progress;
|
||||||
|
if (dlstart && dltotal && dlnow) {
|
||||||
|
time_t done = time(NULL) - dlstart;
|
||||||
|
time_t left = ((dltotal - dlnow) * done)/dlnow;
|
||||||
|
progress = "(" + to_string(done) + "s/" + to_string(left) + "s)";
|
||||||
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
yt_pending_offset = yt_menue->getItemsCount();
|
yt_pending_offset = yt_menue->getItemsCount();
|
||||||
for (std::vector<MI_MOVIE_INFO>::iterator it = yt_pending.begin(); it != yt_pending.end(); ++it, ++i) {
|
for (std::vector<MI_MOVIE_INFO>::iterator it = yt_pending.begin(); it != yt_pending.end(); ++it, ++i) {
|
||||||
yt_menue->addItem(new CMenuForwarder((*it).file.Name.c_str(), true, NULL, ytcache_selector));
|
yt_menue->addItem(new CMenuForwarder((*it).file.Name, true, progress.c_str(), ytcache_selector));
|
||||||
|
progress = "";
|
||||||
}
|
}
|
||||||
yt_pending_end = yt_menue->getItemsCount();
|
yt_pending_end = yt_menue->getItemsCount();
|
||||||
}
|
}
|
||||||
|
@@ -103,9 +103,11 @@ bool cYTCache::useCachedCopy(MI_MOVIE_INFO *mi)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cYTCache::curlProgress(void *clientp, double /*dltotal*/, double /*dlnow*/, double /*ultotal*/, double /*ulnow*/)
|
int cYTCache::curlProgress(void *clientp, double dltotal, double dlnow, double /*ultotal*/, double /*ulnow*/)
|
||||||
{
|
{
|
||||||
cYTCache *caller = (cYTCache *) clientp;
|
cYTCache *caller = (cYTCache *) clientp;
|
||||||
|
caller->dltotal = dltotal;
|
||||||
|
caller->dlnow = dlnow;
|
||||||
if (caller->cancelled)
|
if (caller->cancelled)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -153,6 +155,9 @@ bool cYTCache::download(MI_MOVIE_INFO *mi)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dltotal = 0;
|
||||||
|
dlnow = 0;
|
||||||
|
dlstart = time(NULL);
|
||||||
|
|
||||||
fprintf (stderr, "downloading %s to %s\n", mi->file.Url.c_str(), file.c_str());
|
fprintf (stderr, "downloading %s to %s\n", mi->file.Url.c_str(), file.c_str());
|
||||||
CURLcode res = curl_easy_perform(curl);
|
CURLcode res = curl_easy_perform(curl);
|
||||||
@@ -328,13 +333,28 @@ std::vector<MI_MOVIE_INFO> cYTCache::getCompleted(MI_MOVIE_INFO::miSource source
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MI_MOVIE_INFO> cYTCache::getPending(MI_MOVIE_INFO::miSource source)
|
std::vector<MI_MOVIE_INFO> cYTCache::getPending(MI_MOVIE_INFO::miSource source, double *p_dltotal, double *p_dlnow, time_t *p_start)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||||
std::vector<MI_MOVIE_INFO> res;
|
std::vector<MI_MOVIE_INFO> res;
|
||||||
for (std::vector<MI_MOVIE_INFO>::iterator it = pending.begin(); it != pending.end(); ++it)
|
for (std::vector<MI_MOVIE_INFO>::iterator it = pending.begin(); it != pending.end(); ++it)
|
||||||
if ((*it).source == source)
|
if ((*it).source == source)
|
||||||
res.push_back(*it);
|
res.push_back(*it);
|
||||||
|
if (res.size() > 0 && pending.front().source == source) {
|
||||||
|
if (p_dltotal)
|
||||||
|
*p_dltotal = dltotal;
|
||||||
|
if (p_dlnow)
|
||||||
|
*p_dlnow = dlnow;
|
||||||
|
if (p_start)
|
||||||
|
*p_start = dlstart;
|
||||||
|
} else {
|
||||||
|
if (p_dltotal)
|
||||||
|
*p_dltotal = 0;
|
||||||
|
if (p_dlnow)
|
||||||
|
*p_dlnow = 0;
|
||||||
|
if (p_start)
|
||||||
|
*p_start = 0;
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,6 +47,9 @@ class cYTCache
|
|||||||
static int curlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
static int curlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||||
bool compareMovieInfo(MI_MOVIE_INFO *a, MI_MOVIE_INFO *b);
|
bool compareMovieInfo(MI_MOVIE_INFO *a, MI_MOVIE_INFO *b);
|
||||||
public:
|
public:
|
||||||
|
double dltotal;
|
||||||
|
double dlnow;
|
||||||
|
time_t dlstart;
|
||||||
static cYTCache *getInstance();
|
static cYTCache *getInstance();
|
||||||
cYTCache();
|
cYTCache();
|
||||||
~cYTCache();
|
~cYTCache();
|
||||||
@@ -57,7 +60,7 @@ class cYTCache
|
|||||||
void cancelAll(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT);
|
void cancelAll(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT);
|
||||||
std::vector<MI_MOVIE_INFO> getCompleted(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT);
|
std::vector<MI_MOVIE_INFO> getCompleted(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT);
|
||||||
std::vector<MI_MOVIE_INFO> getFailed(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT);
|
std::vector<MI_MOVIE_INFO> getFailed(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT);
|
||||||
std::vector<MI_MOVIE_INFO> getPending(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT);
|
std::vector<MI_MOVIE_INFO> getPending(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT, double *p_dltotal = NULL, double *p_dlnow = NULL, time_t *p_start = NULL);
|
||||||
void clearCompleted(MI_MOVIE_INFO *mi);
|
void clearCompleted(MI_MOVIE_INFO *mi);
|
||||||
void clearFailed(MI_MOVIE_INFO *mi);
|
void clearFailed(MI_MOVIE_INFO *mi);
|
||||||
void clearCompleted(MI_MOVIE_INFO::miSource source = MI_MOVIE_INFO::YT);
|
void clearCompleted(MI_MOVIE_INFO::miSource source = MI_MOVIE_INFO::YT);
|
||||||
|
Reference in New Issue
Block a user