add gui support for experimental yt caching code

Conflicts:
	data/locale/deutsch.locale
	data/locale/english.locale
	src/gui/moviebrowser.cpp
	src/system/locals.h
	src/system/locals_intern.h


Origin commit data
------------------
Commit: 7fac02ba45
Author: martii <m4rtii@gmx.de>
Date: 2013-06-13 (Thu, 13 Jun 2013)
This commit is contained in:
martii
2013-06-13 21:08:40 +02:00
committed by [CST] Focus
parent ccb410f5ef
commit 3f36f76364
11 changed files with 298 additions and 68 deletions

View File

@@ -1594,8 +1594,15 @@ moviebrowser.update_if_dest_empty_only Übernehmen nur wenn Ziel leer
moviebrowser.use_dir Verzeichnis verwenden
moviebrowser.use_movie_dir Wiedergabeverzeichnis verwenden
moviebrowser.use_rec_dir Aufnahmeverzeichnis verwenden
moviebrowser.yt_cache Downloads
moviebrowser.yt_cache_add Download von\n%s\nwird eingeplant.
moviebrowser.yt_cancel Alle abbrechen
moviebrowser.yt_cancel_transfer Download abbrechen?
moviebrowser.yt_clear Liste leeren
moviebrowser.yt_completed Vollständige Downloads
moviebrowser.yt_concurrent_connections Gleichzeitige Verbindungen
moviebrowser.yt_error Fehler beim laden des Youtube Feed
moviebrowser.yt_error Fehler beim Laden des Youtube-Feeds
moviebrowser.yt_failed Fehlgeschlagene Downloads
moviebrowser.yt_history Frühere Suchen
moviebrowser.yt_max_history Max. Anzahl früherer Suchen
moviebrowser.yt_max_results Max. Anzahl der zu holenden Feeds
@@ -1607,6 +1614,11 @@ moviebrowser.yt_orderby.published Veröffentlichungszeitpunkt
moviebrowser.yt_orderby.rating Bewertung
moviebrowser.yt_orderby.relevance Relevanz
moviebrowser.yt_orderby.viewcount Zahl der Views
moviebrowser.yt_pending Anstehende Downloads
moviebrowser.yt_pref_quality Bevorzugte Qualität
moviebrowser.yt_region Region
moviebrowser.yt_related Passende Videos
moviebrowser.yt_search Suche nach Stichwort
moviebrowser.yt_pref_quality Bevorzugte Qualität
moviebrowser.yt_prev_results Vorherige Ergebnisse
moviebrowser.yt_recently_featured Vor kurzem empfohlen

View File

@@ -1594,8 +1594,15 @@ moviebrowser.update_if_dest_empty_only Copy if destination is empty only
moviebrowser.use_dir Use directory
moviebrowser.use_movie_dir Use movie directory
moviebrowser.use_rec_dir Use record directory
moviebrowser.yt_cache Downloads
moviebrowser.yt_cache_add Download of\n%s\nis scheduled.
moviebrowser.yt_cancel Cancel all
moviebrowser.yt_cancel_transfer Cancel download?
moviebrowser.yt_clear Clear
moviebrowser.yt_completed Completed downloads
moviebrowser.yt_concurrent_connections Concurrent connections
moviebrowser.yt_error Failed to load youtube feed
moviebrowser.yt_failed Failed downloads
moviebrowser.yt_history Search history
moviebrowser.yt_max_history Max search history size
moviebrowser.yt_max_results Max results to fetch
@@ -1607,6 +1614,7 @@ moviebrowser.yt_orderby.published publishing date
moviebrowser.yt_orderby.rating rating
moviebrowser.yt_orderby.relevance relevance
moviebrowser.yt_orderby.viewcount view count
moviebrowser.yt_pending Pending downloads
moviebrowser.yt_pref_quality Prefered quality
moviebrowser.yt_prev_results Previous results
moviebrowser.yt_recently_featured Recently featured

View File

@@ -1100,7 +1100,15 @@ int CMovieBrowser::exec(const char* path)
}
else if ((show_mode == MB_SHOW_YT) && (msg == CRCInput::RC_record) && m_movieSelectionHandler)
{
cYTCache::getInstance()->addToCache(m_movieSelectionHandler);
if (cYTCache::getInstance()->addToCache(m_movieSelectionHandler)) {
const char *format = g_Locale->getText(LOCALE_MOVIEBROWSER_YT_CACHE_ADD);
char buf[1024];
snprintf(buf, sizeof(buf), format, m_movieSelectionHandler->file.Name.c_str());
CHintBox hintBox(LOCALE_MOVIEBROWSER_YT_CACHE, buf);
hintBox.paint();
sleep(1);
hintBox.hide();
}
}
else if (msg == CRCInput::RC_home)
{
@@ -2251,10 +2259,12 @@ void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler, bool skip
{
//TRACE( "[onDeleteFile] ");
int test= movieSelectionHandler.file.Name.find(".ts", movieSelectionHandler.file.Name.length()-3);
if (test < 0)
test= movieSelectionHandler.file.Name.find(".mp4", movieSelectionHandler.file.Name.length()-4);
if(test == -1)
{
// not a TS file, return!!!!!
TRACE( "show_ts_info: not a TS file ");
TRACE( "show_ts_info: not a TS or MP4 file ");
}
else
{
@@ -3750,6 +3760,99 @@ neutrino_locale_t CMovieBrowser::getFeedLocale(void)
return ret;
}
int CYTCacheSelectorTarget::exec(CMenuTarget* /*parent*/, const std::string & actionKey)
{
int selected = movieBrowser->yt_menue->getSelected();
if (actionKey == "cancel_all") {
cYTCache::getInstance()->cancelAll();
} else if (actionKey == "completed_clear") {
cYTCache::getInstance()->clearCompleted();
} else if (actionKey == "failed_clear") {
cYTCache::getInstance()->clearFailed();
} else if (actionKey == "rc_spkr" && selected >= movieBrowser->yt_pending_offset && selected < movieBrowser->yt_completed_offset) {
cYTCache::getInstance()->cancel(&movieBrowser->yt_pending[selected - movieBrowser->yt_pending_offset]);
} else if (actionKey == "rc_spkr" && selected >= movieBrowser->yt_completed_offset && selected < movieBrowser->yt_failed_offset) {
cYTCache::getInstance()->remove(&movieBrowser->yt_completed[selected - movieBrowser->yt_completed_offset]);
} else if (actionKey == "") {
if (selected >= movieBrowser->yt_pending_offset && selected < movieBrowser->yt_completed_offset) {
if(ShowMsg (LOCALE_MOVIEBROWSER_YT_CACHE, g_Locale->getText(LOCALE_MOVIEBROWSER_YT_CANCEL_TRANSFER), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)
cYTCache::getInstance()->cancel(&movieBrowser->yt_pending[selected - movieBrowser->yt_pending_offset]);
else
return menu_return::RETURN_NONE;
} else if (selected >= movieBrowser->yt_completed_offset && selected < movieBrowser->yt_failed_offset) {
// FIXME -- anything sensible to do here?
return menu_return::RETURN_NONE;
} else if (selected >= movieBrowser->yt_failed_offset && selected < movieBrowser->yt_menue->getItemsCount()){
cYTCache::getInstance()->clearFailed(&movieBrowser->yt_failed[selected - movieBrowser->yt_failed_offset]);
cYTCache::getInstance()->addToCache(&movieBrowser->yt_failed[selected - movieBrowser->yt_failed_offset]);
const char *format = g_Locale->getText(LOCALE_MOVIEBROWSER_YT_CACHE_ADD);
char buf[1024];
snprintf(buf, sizeof(buf), format, movieBrowser->yt_failed[selected - movieBrowser->yt_failed_offset].file.Name.c_str());
CHintBox hintBox(LOCALE_MOVIEBROWSER_YT_CACHE, buf);
hintBox.paint();
sleep(1);
hintBox.hide();
}
} else
return menu_return::RETURN_NONE;
movieBrowser->refreshYTMenu();
return menu_return::RETURN_REPAINT;
}
void CMovieBrowser::refreshYTMenu()
{
for (u_int item_id = (u_int) yt_menue->getItemsCount() - 1; item_id > yt_menue_end - 1; item_id--) {
CMenuItem* m = yt_menue->getItem(item_id);
if (m && !m->isStatic) {
delete m;
yt_menue->removeItem(item_id);
}
}
yt_pending = cYTCache::getInstance()->getPending();
yt_completed = cYTCache::getInstance()->getCompleted();
yt_failed = cYTCache::getInstance()->getFailed();
yt_pending_offset = 0;
yt_completed_offset = 0;
yt_failed_offset = 0;
if (!yt_pending.empty()) {
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(GenericMenuSeparator);
int i = 0;
yt_pending_offset = yt_menue->getItemsCount();
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));
}
}
if (!yt_completed.empty()) {
yt_menue->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MOVIEBROWSER_YT_COMPLETED));
yt_menue->addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_CLEAR, true, NULL, ytcache_selector, "completed_clear"));
yt_menue->addItem(GenericMenuSeparator);
int i = 0;
yt_completed_offset = yt_menue->getItemsCount();
for (std::vector<MI_MOVIE_INFO>::iterator it = yt_completed.begin(); it != yt_completed.end(); ++it, ++i) {
yt_menue->addItem(new CMenuForwarder((*it).file.Name.c_str(), true, NULL, ytcache_selector));
}
}
if (!yt_failed.empty()) {
yt_menue->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MOVIEBROWSER_YT_FAILED));
yt_menue->addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_CLEAR, true, NULL, ytcache_selector, "failed_clear"));
yt_menue->addItem(GenericMenuSeparator);
int i = 0;
yt_failed_offset = yt_menue->getItemsCount();
for (std::vector<MI_MOVIE_INFO>::iterator it = yt_failed.begin(); it != yt_failed.end(); ++it, ++i) {
yt_menue->addItem(new CMenuForwarder((*it).file.Name.c_str(), true, NULL, ytcache_selector));
}
}
CFrameBuffer::getInstance()->Clear(); // due to possible width change
}
class CYTHistory : public CMenuTarget
{
private:
@@ -3869,7 +3972,16 @@ bool CMovieBrowser::showYTMenu()
mainMenu.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_YT_PREF_QUALITY, &m_settings.ytquality, YT_QUALITY_OPTIONS, YT_QUALITY_OPTION_COUNT, true, NULL, CRCInput::RC_nokey, "", true));
mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_CONCURRENT_CONNECTIONS, &m_settings.ytconcconn, true, 1, 8));
yt_menue = &mainMenu;
yt_menue_end = yt_menue->getItemsCount();
CYTCacheSelectorTarget ytcache_sel(this);
ytcache_selector = &ytcache_sel;
yt_menue->addKey(CRCInput::RC_spkr, ytcache_selector, "rc_spkr");
refreshYTMenu();
mainMenu.exec(NULL, "");
ytparser.SetConcurrentDownloads(m_settings.ytconcconn);
delete selector;

View File

@@ -241,9 +241,22 @@ typedef struct
std::list<std::string> ytsearch_history;
} MB_SETTINGS;
class CMovieBrowser;
class CYTCacheSelectorTarget : public CMenuTarget
{
private:
class CMovieBrowser *movieBrowser;
public:
CYTCacheSelectorTarget(CMovieBrowser *mb) { movieBrowser = mb; };
int exec(CMenuTarget* parent, const std::string & actionKey);
};
// Priorities for Developmemt: P1: critical feature, P2: important feature, P3: for next release, P4: looks nice, lets see
class CMovieBrowser : public CMenuTarget
{
friend class CYTCacheSelectorTarget;
public: // Variables /////////////////////////////////////////////////
int Multi_Select; // for FileBrowser compatibility, not used in MovieBrowser
int Dirs_Selectable; // for FileBrowser compatibility, not used in MovieBrowser
@@ -327,8 +340,18 @@ class CMovieBrowser : public CMenuTarget
cYTFeedParser ytparser;
int show_mode;
CMenuWidget *yt_menue;
CYTCacheSelectorTarget *ytcache_selector;
u_int yt_menue_end;
int yt_pending_offset;
int yt_completed_offset;
int yt_failed_offset;
std::vector<MI_MOVIE_INFO> yt_pending;
std::vector<MI_MOVIE_INFO> yt_completed;
std::vector<MI_MOVIE_INFO> yt_failed;
void loadYTitles(int mode, std::string search = "", std::string id = "");
bool showYTMenu(void);
void refreshYTMenu();
public: // Functions //////////////////////////////////////////////////////////7
CMovieBrowser(const char* path); //P1

View File

@@ -1019,7 +1019,7 @@ bool CMovieInfo::saveFile_vlc(const CFile & /*file*/, const char */*text*/, cons
*
* */
#if 0
#if 1
MI_MOVIE_INFO& MI_MOVIE_INFO::operator=(const MI_MOVIE_INFO& src)
{
file.Name = src.file.Name;

View File

@@ -146,7 +146,7 @@ typedef struct
class MI_MOVIE_INFO
{
public:
// MI_MOVIE_INFO &operator=(const MI_MOVIE_INFO& src);
MI_MOVIE_INFO &operator=(const MI_MOVIE_INFO& src);
CFile file; // not stored in xml
std::string productionCountry; // user defined Country (not from EPG yet, but might be possible)
std::string epgTitle; // plain movie name, usually filled by EPG

View File

@@ -1621,8 +1621,15 @@ typedef enum
LOCALE_MOVIEBROWSER_USE_DIR,
LOCALE_MOVIEBROWSER_USE_MOVIE_DIR,
LOCALE_MOVIEBROWSER_USE_REC_DIR,
LOCALE_MOVIEBROWSER_YT_CACHE,
LOCALE_MOVIEBROWSER_YT_CACHE_ADD,
LOCALE_MOVIEBROWSER_YT_CANCEL,
LOCALE_MOVIEBROWSER_YT_CANCEL_TRANSFER,
LOCALE_MOVIEBROWSER_YT_CLEAR,
LOCALE_MOVIEBROWSER_YT_COMPLETED,
LOCALE_MOVIEBROWSER_YT_CONCURRENT_CONNECTIONS,
LOCALE_MOVIEBROWSER_YT_ERROR,
LOCALE_MOVIEBROWSER_YT_FAILED,
LOCALE_MOVIEBROWSER_YT_HISTORY,
LOCALE_MOVIEBROWSER_YT_MAX_HISTORY,
LOCALE_MOVIEBROWSER_YT_MAX_RESULTS,
@@ -1634,6 +1641,7 @@ typedef enum
LOCALE_MOVIEBROWSER_YT_ORDERBY_RATING,
LOCALE_MOVIEBROWSER_YT_ORDERBY_RELEVANCE,
LOCALE_MOVIEBROWSER_YT_ORDERBY_VIEWCOUNT,
LOCALE_MOVIEBROWSER_YT_PENDING,
LOCALE_MOVIEBROWSER_YT_PREF_QUALITY,
LOCALE_MOVIEBROWSER_YT_PREV_RESULTS,
LOCALE_MOVIEBROWSER_YT_RECENTLY_FEATURED,

View File

@@ -1621,8 +1621,15 @@ const char * locale_real_names[] =
"moviebrowser.use_dir",
"moviebrowser.use_movie_dir",
"moviebrowser.use_rec_dir",
"moviebrowser.yt_cache",
"moviebrowser.yt_cache_add",
"moviebrowser.yt_cancel",
"moviebrowser.yt_cancel_transfer",
"moviebrowser.yt_clear",
"moviebrowser.yt_completed",
"moviebrowser.yt_concurrent_connections",
"moviebrowser.yt_error",
"moviebrowser.yt_failed",
"moviebrowser.yt_history",
"moviebrowser.yt_max_history",
"moviebrowser.yt_max_results",
@@ -1634,6 +1641,7 @@ const char * locale_real_names[] =
"moviebrowser.yt_orderby.rating",
"moviebrowser.yt_orderby.relevance",
"moviebrowser.yt_orderby.viewcount",
"moviebrowser.yt_pending",
"moviebrowser.yt_pref_quality",
"moviebrowser.yt_prev_results",
"moviebrowser.yt_recently_featured",

View File

@@ -34,6 +34,7 @@
#include "helpers.h"
#include "settings.h"
#include "set_threadname.h"
#include <global.h>
static cYTCache *instance = NULL;
@@ -66,11 +67,14 @@ std::string cYTCache::getName(MI_MOVIE_INFO *mi, std::string ext)
bool cYTCache::useCachedCopy(MI_MOVIE_INFO *mi)
{
std::string file = getName(mi);
fprintf(stderr, "checking %s\n", file.c_str());
if (access(file.c_str(), R_OK))
return false;
std::string xml = getName(mi, "xml");
fprintf(stderr, "checking %s\n", xml.c_str());
if (!access(xml.c_str(), R_OK)) {
mi->file.Url = file;
fprintf(stderr, "using cached copy: %s\n", file.c_str());
return true;
}
{
@@ -99,8 +103,10 @@ bool cYTCache::download(MI_MOVIE_INFO *mi)
{
std::string file = getName(mi);
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(xml.c_str(), R_OK)) {
fprintf(stderr, "%s: %s already present an valid\n", __func__, file.c_str());
return true;
}
FILE * fp = fopen(file.c_str(), "wb");
if (!fp) {
@@ -132,7 +138,6 @@ bool cYTCache::download(MI_MOVIE_INFO *mi)
fclose(fp);
if (res) {
fprintf(stderr, "curl error: %s\n", cerror);
unlink(file.c_str());
return false;
}
@@ -147,6 +152,8 @@ bool cYTCache::download(MI_MOVIE_INFO *mi)
}
void *cYTCache::downloadThread(void *arg) {
fprintf(stderr, "%s starting\n", __func__);
set_threadname("ytdownload");
cYTCache *caller = (cYTCache *)arg;
while (caller->thread) {
@@ -161,32 +168,33 @@ void *cYTCache::downloadThread(void *arg) {
mi = caller->pending.front();
}
fprintf(stderr, "download start: %s\n", mi.file.Url.c_str());
bool res = caller->download(&mi);
fprintf(stderr, "download end: %s %s\n", mi.file.Url.c_str(), res ? "succeeded" : "failed");
caller->cancelled = false;
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(caller->mutex);
if (res)
caller->done.push_front(mi);
caller->completed.insert(caller->completed.begin(), mi);
else
caller->failed.push_front(mi);
caller->cancelled = false;
caller->failed.insert(caller->failed.begin(), mi);
if (caller->pending.empty())
caller->thread = 0;
else
caller->pending.pop_front();
caller->pending.erase(caller->pending.begin());
}
}
fprintf(stderr, "%s exiting\n", __func__);
pthread_exit(NULL);
}
bool cYTCache::addToCache(MI_MOVIE_INFO *mi)
{
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
pending.push_back(*mi);
}
if (!thread) {
if (pthread_create(&thread, NULL, downloadThread, this)) {
@@ -200,62 +208,111 @@ bool cYTCache::addToCache(MI_MOVIE_INFO *mi)
void cYTCache::cancel(MI_MOVIE_INFO *mi)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
mutex.lock();
if (pending.empty())
return;
if (compareMovieInfo(mi, &pending.front())) {
cancelled = true;
mutex.unlock();
while (cancelled)
usleep(100000);
return;
}
for (std::list<MI_MOVIE_INFO>::iterator it = pending.begin(); it != pending.end(); ++it)
} else {
for (std::vector<MI_MOVIE_INFO>::iterator it = pending.begin(); it != pending.end(); ++it)
if (compareMovieInfo(&(*it), mi)) {
pending.erase(it);
failed.push_back(*mi);
break;
}
}
mutex.unlock();
}
void cYTCache::remove(MI_MOVIE_INFO *mi)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
if (completed.empty())
return;
for (std::vector<MI_MOVIE_INFO>::iterator it = completed.begin(); it != completed.end(); ++it)
if (compareMovieInfo(&(*it), mi)) {
completed.erase(it);
unlink(getName(mi).c_str());
unlink(getName(mi, "xml").c_str());
unlink(getName(mi, "jpg").c_str());
break;
}
}
void cYTCache::cancelAll(void)
{
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
if (pending.empty())
return;
if (pending.size() > 1) {
failed.insert(failed.end(), pending.begin() + 1, pending.end());
pending.erase(pending.begin() + 1, pending.end());
}
}
cancelled = true;
while (thread)
usleep(100000);
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
cancelled = false;
pending.clear();
}
}
std::list<MI_MOVIE_INFO> cYTCache::getFailed(bool clear)
std::vector<MI_MOVIE_INFO> cYTCache::getFailed(void)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
std::list<MI_MOVIE_INFO> res = failed;
if (clear)
failed.clear();
std::vector<MI_MOVIE_INFO> res = failed;
return res;
}
std::list<MI_MOVIE_INFO> cYTCache::getDone(bool clear)
std::vector<MI_MOVIE_INFO> cYTCache::getCompleted(void)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
std::list<MI_MOVIE_INFO> res = done;
if (clear)
done.clear();
std::vector<MI_MOVIE_INFO> res = completed;
return res;
}
void cYTCache::clearFailed(void)
std::vector<MI_MOVIE_INFO> cYTCache::getPending(void)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
std::vector<MI_MOVIE_INFO> res = pending;
return res;
}
void cYTCache::clearFailed(MI_MOVIE_INFO *mi)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
if (mi) {
for (std::vector<MI_MOVIE_INFO>::iterator it = failed.begin(); it != failed.end(); ++it)
if (compareMovieInfo(&(*it), mi)) {
failed.erase(it);
break;
}
} else
failed.clear();
}
void cYTCache::clearDone(void)
void cYTCache::clearCompleted(MI_MOVIE_INFO *mi)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
done.clear();
if (mi) {
for (std::vector<MI_MOVIE_INFO>::iterator it = completed.begin(); it != completed.end(); ++it)
if (compareMovieInfo(&(*it), mi)) {
completed.erase(it);
break;
}
} else
completed.clear();
}
bool cYTCache::compareMovieInfo(MI_MOVIE_INFO *a, MI_MOVIE_INFO *b)

View File

@@ -25,7 +25,7 @@
#include <config.h>
#include <string>
#include <list>
#include <vector>
#include <OpenThreads/Thread>
#include <OpenThreads/Condition>
@@ -37,9 +37,9 @@ class cYTCache
private:
pthread_t thread;
bool cancelled;
std::list<MI_MOVIE_INFO> pending;
std::list<MI_MOVIE_INFO> done;
std::list<MI_MOVIE_INFO> failed;
std::vector<MI_MOVIE_INFO> pending;
std::vector<MI_MOVIE_INFO> completed;
std::vector<MI_MOVIE_INFO> failed;
OpenThreads::Mutex mutex;
bool download(MI_MOVIE_INFO *mi);
std::string getName(MI_MOVIE_INFO *mi, std::string ext = "mp4");
@@ -53,10 +53,12 @@ class cYTCache
bool useCachedCopy(MI_MOVIE_INFO *mi);
bool addToCache(MI_MOVIE_INFO *mi);
void cancel(MI_MOVIE_INFO *mi);
void remove(MI_MOVIE_INFO *mi);
void cancelAll(void);
std::list<MI_MOVIE_INFO> getDone(bool clear = false);
std::list<MI_MOVIE_INFO> getFailed(bool clear = false);
void clearDone(void);
void clearFailed(void);
std::vector<MI_MOVIE_INFO> getCompleted(void);
std::vector<MI_MOVIE_INFO> getFailed(void);
std::vector<MI_MOVIE_INFO> getPending(void);
void clearCompleted(MI_MOVIE_INFO *mi = NULL);
void clearFailed(MI_MOVIE_INFO *mi = NULL);
};
#endif

View File

@@ -70,7 +70,7 @@ std::string cYTVideoInfo::GetUrl(int *fmt, bool mandatory)
fmt = &default_fmt;
yt_urlmap_iterator_t it;
if (*fmt) {
if (fmt) {
if ((it = formats.find(*fmt)) != formats.end()) {
return it->second.GetUrl();
}