mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 00:41:09 +02:00
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:
@@ -1594,8 +1594,15 @@ moviebrowser.update_if_dest_empty_only Übernehmen nur wenn Ziel leer
|
|||||||
moviebrowser.use_dir Verzeichnis verwenden
|
moviebrowser.use_dir Verzeichnis verwenden
|
||||||
moviebrowser.use_movie_dir Wiedergabeverzeichnis verwenden
|
moviebrowser.use_movie_dir Wiedergabeverzeichnis verwenden
|
||||||
moviebrowser.use_rec_dir Aufnahmeverzeichnis 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_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_history Frühere Suchen
|
||||||
moviebrowser.yt_max_history Max. Anzahl früherer Suchen
|
moviebrowser.yt_max_history Max. Anzahl früherer Suchen
|
||||||
moviebrowser.yt_max_results Max. Anzahl der zu holenden Feeds
|
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.rating Bewertung
|
||||||
moviebrowser.yt_orderby.relevance Relevanz
|
moviebrowser.yt_orderby.relevance Relevanz
|
||||||
moviebrowser.yt_orderby.viewcount Zahl der Views
|
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_pref_quality Bevorzugte Qualität
|
||||||
moviebrowser.yt_prev_results Vorherige Ergebnisse
|
moviebrowser.yt_prev_results Vorherige Ergebnisse
|
||||||
moviebrowser.yt_recently_featured Vor kurzem empfohlen
|
moviebrowser.yt_recently_featured Vor kurzem empfohlen
|
||||||
|
@@ -1594,8 +1594,15 @@ moviebrowser.update_if_dest_empty_only Copy if destination is empty only
|
|||||||
moviebrowser.use_dir Use directory
|
moviebrowser.use_dir Use directory
|
||||||
moviebrowser.use_movie_dir Use movie directory
|
moviebrowser.use_movie_dir Use movie directory
|
||||||
moviebrowser.use_rec_dir Use record 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_concurrent_connections Concurrent connections
|
||||||
moviebrowser.yt_error Failed to load youtube feed
|
moviebrowser.yt_error Failed to load youtube feed
|
||||||
|
moviebrowser.yt_failed Failed downloads
|
||||||
moviebrowser.yt_history Search history
|
moviebrowser.yt_history Search history
|
||||||
moviebrowser.yt_max_history Max search history size
|
moviebrowser.yt_max_history Max search history size
|
||||||
moviebrowser.yt_max_results Max results to fetch
|
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.rating rating
|
||||||
moviebrowser.yt_orderby.relevance relevance
|
moviebrowser.yt_orderby.relevance relevance
|
||||||
moviebrowser.yt_orderby.viewcount view count
|
moviebrowser.yt_orderby.viewcount view count
|
||||||
|
moviebrowser.yt_pending Pending downloads
|
||||||
moviebrowser.yt_pref_quality Prefered quality
|
moviebrowser.yt_pref_quality Prefered quality
|
||||||
moviebrowser.yt_prev_results Previous results
|
moviebrowser.yt_prev_results Previous results
|
||||||
moviebrowser.yt_recently_featured Recently featured
|
moviebrowser.yt_recently_featured Recently featured
|
||||||
|
@@ -1100,7 +1100,15 @@ int CMovieBrowser::exec(const char* path)
|
|||||||
}
|
}
|
||||||
else if ((show_mode == MB_SHOW_YT) && (msg == CRCInput::RC_record) && m_movieSelectionHandler)
|
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)
|
else if (msg == CRCInput::RC_home)
|
||||||
{
|
{
|
||||||
@@ -2251,10 +2259,12 @@ void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler, bool skip
|
|||||||
{
|
{
|
||||||
//TRACE( "[onDeleteFile] ");
|
//TRACE( "[onDeleteFile] ");
|
||||||
int test= movieSelectionHandler.file.Name.find(".ts", movieSelectionHandler.file.Name.length()-3);
|
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)
|
if(test == -1)
|
||||||
{
|
{
|
||||||
// not a TS file, return!!!!!
|
// not a TS file, return!!!!!
|
||||||
TRACE( "show_ts_info: not a TS file ");
|
TRACE( "show_ts_info: not a TS or MP4 file ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3750,6 +3760,99 @@ neutrino_locale_t CMovieBrowser::getFeedLocale(void)
|
|||||||
return ret;
|
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
|
class CYTHistory : public CMenuTarget
|
||||||
{
|
{
|
||||||
private:
|
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 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));
|
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, "");
|
mainMenu.exec(NULL, "");
|
||||||
|
|
||||||
ytparser.SetConcurrentDownloads(m_settings.ytconcconn);
|
ytparser.SetConcurrentDownloads(m_settings.ytconcconn);
|
||||||
delete selector;
|
delete selector;
|
||||||
|
|
||||||
|
@@ -241,9 +241,22 @@ typedef struct
|
|||||||
std::list<std::string> ytsearch_history;
|
std::list<std::string> ytsearch_history;
|
||||||
} MB_SETTINGS;
|
} 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
|
// Priorities for Developmemt: P1: critical feature, P2: important feature, P3: for next release, P4: looks nice, lets see
|
||||||
class CMovieBrowser : public CMenuTarget
|
class CMovieBrowser : public CMenuTarget
|
||||||
{
|
{
|
||||||
|
friend class CYTCacheSelectorTarget;
|
||||||
|
|
||||||
public: // Variables /////////////////////////////////////////////////
|
public: // Variables /////////////////////////////////////////////////
|
||||||
int Multi_Select; // for FileBrowser compatibility, not used in MovieBrowser
|
int Multi_Select; // for FileBrowser compatibility, not used in MovieBrowser
|
||||||
int Dirs_Selectable; // 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;
|
cYTFeedParser ytparser;
|
||||||
int show_mode;
|
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 = "");
|
void loadYTitles(int mode, std::string search = "", std::string id = "");
|
||||||
bool showYTMenu(void);
|
bool showYTMenu(void);
|
||||||
|
void refreshYTMenu();
|
||||||
|
|
||||||
public: // Functions //////////////////////////////////////////////////////////7
|
public: // Functions //////////////////////////////////////////////////////////7
|
||||||
CMovieBrowser(const char* path); //P1
|
CMovieBrowser(const char* path); //P1
|
||||||
@@ -369,7 +392,7 @@ class CMovieBrowser : public CMenuTarget
|
|||||||
///// MovieBrowser Main Window//////////
|
///// MovieBrowser Main Window//////////
|
||||||
int paint(void); //P1
|
int paint(void); //P1
|
||||||
void refresh(void); //P1
|
void refresh(void); //P1
|
||||||
void hide(void); //P1
|
void hide(void); //P1
|
||||||
void refreshLastPlayList(void); //P2
|
void refreshLastPlayList(void); //P2
|
||||||
void refreshLastRecordList(void); //P2
|
void refreshLastRecordList(void); //P2
|
||||||
void refreshBrowserList(void); //P1
|
void refreshBrowserList(void); //P1
|
||||||
|
@@ -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)
|
MI_MOVIE_INFO& MI_MOVIE_INFO::operator=(const MI_MOVIE_INFO& src)
|
||||||
{
|
{
|
||||||
file.Name = src.file.Name;
|
file.Name = src.file.Name;
|
||||||
|
@@ -146,7 +146,7 @@ typedef struct
|
|||||||
class MI_MOVIE_INFO
|
class MI_MOVIE_INFO
|
||||||
{
|
{
|
||||||
public:
|
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
|
CFile file; // not stored in xml
|
||||||
std::string productionCountry; // user defined Country (not from EPG yet, but might be possible)
|
std::string productionCountry; // user defined Country (not from EPG yet, but might be possible)
|
||||||
std::string epgTitle; // plain movie name, usually filled by EPG
|
std::string epgTitle; // plain movie name, usually filled by EPG
|
||||||
|
@@ -1621,8 +1621,15 @@ typedef enum
|
|||||||
LOCALE_MOVIEBROWSER_USE_DIR,
|
LOCALE_MOVIEBROWSER_USE_DIR,
|
||||||
LOCALE_MOVIEBROWSER_USE_MOVIE_DIR,
|
LOCALE_MOVIEBROWSER_USE_MOVIE_DIR,
|
||||||
LOCALE_MOVIEBROWSER_USE_REC_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_CONCURRENT_CONNECTIONS,
|
||||||
LOCALE_MOVIEBROWSER_YT_ERROR,
|
LOCALE_MOVIEBROWSER_YT_ERROR,
|
||||||
|
LOCALE_MOVIEBROWSER_YT_FAILED,
|
||||||
LOCALE_MOVIEBROWSER_YT_HISTORY,
|
LOCALE_MOVIEBROWSER_YT_HISTORY,
|
||||||
LOCALE_MOVIEBROWSER_YT_MAX_HISTORY,
|
LOCALE_MOVIEBROWSER_YT_MAX_HISTORY,
|
||||||
LOCALE_MOVIEBROWSER_YT_MAX_RESULTS,
|
LOCALE_MOVIEBROWSER_YT_MAX_RESULTS,
|
||||||
@@ -1634,6 +1641,7 @@ typedef enum
|
|||||||
LOCALE_MOVIEBROWSER_YT_ORDERBY_RATING,
|
LOCALE_MOVIEBROWSER_YT_ORDERBY_RATING,
|
||||||
LOCALE_MOVIEBROWSER_YT_ORDERBY_RELEVANCE,
|
LOCALE_MOVIEBROWSER_YT_ORDERBY_RELEVANCE,
|
||||||
LOCALE_MOVIEBROWSER_YT_ORDERBY_VIEWCOUNT,
|
LOCALE_MOVIEBROWSER_YT_ORDERBY_VIEWCOUNT,
|
||||||
|
LOCALE_MOVIEBROWSER_YT_PENDING,
|
||||||
LOCALE_MOVIEBROWSER_YT_PREF_QUALITY,
|
LOCALE_MOVIEBROWSER_YT_PREF_QUALITY,
|
||||||
LOCALE_MOVIEBROWSER_YT_PREV_RESULTS,
|
LOCALE_MOVIEBROWSER_YT_PREV_RESULTS,
|
||||||
LOCALE_MOVIEBROWSER_YT_RECENTLY_FEATURED,
|
LOCALE_MOVIEBROWSER_YT_RECENTLY_FEATURED,
|
||||||
|
@@ -810,10 +810,10 @@ const char * locale_real_names[] =
|
|||||||
"keybindingmenu.subchanneldown",
|
"keybindingmenu.subchanneldown",
|
||||||
"keybindingmenu.subchannelup",
|
"keybindingmenu.subchannelup",
|
||||||
"keybindingmenu.tvradiomode",
|
"keybindingmenu.tvradiomode",
|
||||||
"keybindingmenu.video",
|
"keybindingmenu.video",
|
||||||
"keybindingmenu.volume",
|
"keybindingmenu.volume",
|
||||||
"keybindingmenu.volumedown",
|
"keybindingmenu.volumedown",
|
||||||
"keybindingmenu.volumeup",
|
"keybindingmenu.volumeup",
|
||||||
"keybindingmenu.zaphistory",
|
"keybindingmenu.zaphistory",
|
||||||
"keychooser.head",
|
"keychooser.head",
|
||||||
"keychooser.text1",
|
"keychooser.text1",
|
||||||
@@ -1075,8 +1075,8 @@ const char * locale_real_names[] =
|
|||||||
"menu.hint_key_transponder",
|
"menu.hint_key_transponder",
|
||||||
"menu.hint_key_tvradiomode",
|
"menu.hint_key_tvradiomode",
|
||||||
"menu.hint_key_unlock",
|
"menu.hint_key_unlock",
|
||||||
"menu.hint_key_volumedown",
|
"menu.hint_key_volumedown",
|
||||||
"menu.hint_key_volumeup",
|
"menu.hint_key_volumeup",
|
||||||
"menu.hint_keys",
|
"menu.hint_keys",
|
||||||
"menu.hint_lang_pref",
|
"menu.hint_lang_pref",
|
||||||
"menu.hint_language",
|
"menu.hint_language",
|
||||||
@@ -1621,8 +1621,15 @@ const char * locale_real_names[] =
|
|||||||
"moviebrowser.use_dir",
|
"moviebrowser.use_dir",
|
||||||
"moviebrowser.use_movie_dir",
|
"moviebrowser.use_movie_dir",
|
||||||
"moviebrowser.use_rec_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_concurrent_connections",
|
||||||
"moviebrowser.yt_error",
|
"moviebrowser.yt_error",
|
||||||
|
"moviebrowser.yt_failed",
|
||||||
"moviebrowser.yt_history",
|
"moviebrowser.yt_history",
|
||||||
"moviebrowser.yt_max_history",
|
"moviebrowser.yt_max_history",
|
||||||
"moviebrowser.yt_max_results",
|
"moviebrowser.yt_max_results",
|
||||||
@@ -1634,6 +1641,7 @@ const char * locale_real_names[] =
|
|||||||
"moviebrowser.yt_orderby.rating",
|
"moviebrowser.yt_orderby.rating",
|
||||||
"moviebrowser.yt_orderby.relevance",
|
"moviebrowser.yt_orderby.relevance",
|
||||||
"moviebrowser.yt_orderby.viewcount",
|
"moviebrowser.yt_orderby.viewcount",
|
||||||
|
"moviebrowser.yt_pending",
|
||||||
"moviebrowser.yt_pref_quality",
|
"moviebrowser.yt_pref_quality",
|
||||||
"moviebrowser.yt_prev_results",
|
"moviebrowser.yt_prev_results",
|
||||||
"moviebrowser.yt_recently_featured",
|
"moviebrowser.yt_recently_featured",
|
||||||
@@ -1859,11 +1867,11 @@ const char * locale_real_names[] =
|
|||||||
"pinprotection.wrongcode",
|
"pinprotection.wrongcode",
|
||||||
"plugins.hdd_dir",
|
"plugins.hdd_dir",
|
||||||
"plugins.result",
|
"plugins.result",
|
||||||
"plugintype.disabled",
|
"plugintype.disabled",
|
||||||
"plugintype.game",
|
"plugintype.game",
|
||||||
"plugintype.lua",
|
"plugintype.lua",
|
||||||
"plugintype.script",
|
"plugintype.script",
|
||||||
"plugintype.tool",
|
"plugintype.tool",
|
||||||
"rclock.lockmsg",
|
"rclock.lockmsg",
|
||||||
"rclock.menueadd",
|
"rclock.menueadd",
|
||||||
"rclock.title",
|
"rclock.title",
|
||||||
@@ -2202,9 +2210,9 @@ const char * locale_real_names[] =
|
|||||||
"usermenu.item_none",
|
"usermenu.item_none",
|
||||||
"usermenu.item_plugin_types",
|
"usermenu.item_plugin_types",
|
||||||
"usermenu.item_vtxt",
|
"usermenu.item_vtxt",
|
||||||
"usermenu.items",
|
"usermenu.items",
|
||||||
"usermenu.key",
|
"usermenu.key",
|
||||||
"usermenu.key_select",
|
"usermenu.key_select",
|
||||||
"usermenu.msg_info_is_empty",
|
"usermenu.msg_info_is_empty",
|
||||||
"usermenu.msg_warning_name",
|
"usermenu.msg_warning_name",
|
||||||
"usermenu.msg_warning_no_items",
|
"usermenu.msg_warning_no_items",
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "set_threadname.h"
|
||||||
#include <global.h>
|
#include <global.h>
|
||||||
|
|
||||||
static cYTCache *instance = NULL;
|
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)
|
bool cYTCache::useCachedCopy(MI_MOVIE_INFO *mi)
|
||||||
{
|
{
|
||||||
std::string file = getName(mi);
|
std::string file = getName(mi);
|
||||||
|
fprintf(stderr, "checking %s\n", file.c_str());
|
||||||
if (access(file.c_str(), R_OK))
|
if (access(file.c_str(), R_OK))
|
||||||
return false;
|
return false;
|
||||||
std::string xml = getName(mi, "xml");
|
std::string xml = getName(mi, "xml");
|
||||||
|
fprintf(stderr, "checking %s\n", xml.c_str());
|
||||||
if (!access(xml.c_str(), R_OK)) {
|
if (!access(xml.c_str(), R_OK)) {
|
||||||
mi->file.Url = file;
|
mi->file.Url = file;
|
||||||
|
fprintf(stderr, "using cached copy: %s\n", file.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -99,8 +103,10 @@ bool cYTCache::download(MI_MOVIE_INFO *mi)
|
|||||||
{
|
{
|
||||||
std::string file = getName(mi);
|
std::string file = getName(mi);
|
||||||
std::string xml = getName(mi, "xml");
|
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;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
FILE * fp = fopen(file.c_str(), "wb");
|
FILE * fp = fopen(file.c_str(), "wb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
@@ -132,7 +138,6 @@ bool cYTCache::download(MI_MOVIE_INFO *mi)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
fprintf(stderr, "curl error: %s\n", cerror);
|
|
||||||
unlink(file.c_str());
|
unlink(file.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -147,6 +152,8 @@ bool cYTCache::download(MI_MOVIE_INFO *mi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *cYTCache::downloadThread(void *arg) {
|
void *cYTCache::downloadThread(void *arg) {
|
||||||
|
fprintf(stderr, "%s starting\n", __func__);
|
||||||
|
set_threadname("ytdownload");
|
||||||
cYTCache *caller = (cYTCache *)arg;
|
cYTCache *caller = (cYTCache *)arg;
|
||||||
|
|
||||||
while (caller->thread) {
|
while (caller->thread) {
|
||||||
@@ -161,32 +168,33 @@ void *cYTCache::downloadThread(void *arg) {
|
|||||||
mi = caller->pending.front();
|
mi = caller->pending.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "download start: %s\n", mi.file.Url.c_str());
|
|
||||||
|
|
||||||
bool res = caller->download(&mi);
|
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);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(caller->mutex);
|
||||||
if (res)
|
if (res)
|
||||||
caller->done.push_front(mi);
|
caller->completed.insert(caller->completed.begin(), mi);
|
||||||
else
|
else
|
||||||
caller->failed.push_front(mi);
|
caller->failed.insert(caller->failed.begin(), mi);
|
||||||
caller->cancelled = false;
|
|
||||||
if (caller->pending.empty())
|
if (caller->pending.empty())
|
||||||
caller->thread = 0;
|
caller->thread = 0;
|
||||||
else
|
else
|
||||||
caller->pending.pop_front();
|
caller->pending.erase(caller->pending.begin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, "%s exiting\n", __func__);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cYTCache::addToCache(MI_MOVIE_INFO *mi)
|
bool cYTCache::addToCache(MI_MOVIE_INFO *mi)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
{
|
||||||
pending.push_back(*mi);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||||
|
pending.push_back(*mi);
|
||||||
|
}
|
||||||
|
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
if (pthread_create(&thread, NULL, downloadThread, this)) {
|
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)
|
void cYTCache::cancel(MI_MOVIE_INFO *mi)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
mutex.lock();
|
||||||
if (pending.empty())
|
if (pending.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (compareMovieInfo(mi, &pending.front())) {
|
if (compareMovieInfo(mi, &pending.front())) {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
|
mutex.unlock();
|
||||||
|
while (cancelled)
|
||||||
|
usleep(100000);
|
||||||
return;
|
return;
|
||||||
|
} 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (std::list<MI_MOVIE_INFO>::iterator it = pending.begin(); it != pending.end(); ++it)
|
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)) {
|
if (compareMovieInfo(&(*it), mi)) {
|
||||||
pending.erase(it);
|
completed.erase(it);
|
||||||
|
unlink(getName(mi).c_str());
|
||||||
|
unlink(getName(mi, "xml").c_str());
|
||||||
|
unlink(getName(mi, "jpg").c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cYTCache::cancelAll(void)
|
void cYTCache::cancelAll(void)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
{
|
||||||
if (pending.empty())
|
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||||
return;
|
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;
|
cancelled = true;
|
||||||
while (thread)
|
while (thread)
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
cancelled = false;
|
|
||||||
pending.clear();
|
{
|
||||||
|
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);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||||
std::list<MI_MOVIE_INFO> res = failed;
|
std::vector<MI_MOVIE_INFO> res = failed;
|
||||||
if (clear)
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<MI_MOVIE_INFO> cYTCache::getCompleted(void)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||||
|
std::vector<MI_MOVIE_INFO> res = completed;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
failed.clear();
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<MI_MOVIE_INFO> cYTCache::getDone(bool clear)
|
void cYTCache::clearCompleted(MI_MOVIE_INFO *mi)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||||
std::list<MI_MOVIE_INFO> res = done;
|
if (mi) {
|
||||||
if (clear)
|
for (std::vector<MI_MOVIE_INFO>::iterator it = completed.begin(); it != completed.end(); ++it)
|
||||||
done.clear();
|
if (compareMovieInfo(&(*it), mi)) {
|
||||||
return res;
|
completed.erase(it);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
void cYTCache::clearFailed(void)
|
} else
|
||||||
{
|
completed.clear();
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
|
||||||
failed.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cYTCache::clearDone(void)
|
|
||||||
{
|
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
|
||||||
done.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cYTCache::compareMovieInfo(MI_MOVIE_INFO *a, MI_MOVIE_INFO *b)
|
bool cYTCache::compareMovieInfo(MI_MOVIE_INFO *a, MI_MOVIE_INFO *b)
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <vector>
|
||||||
|
|
||||||
#include <OpenThreads/Thread>
|
#include <OpenThreads/Thread>
|
||||||
#include <OpenThreads/Condition>
|
#include <OpenThreads/Condition>
|
||||||
@@ -37,9 +37,9 @@ class cYTCache
|
|||||||
private:
|
private:
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
bool cancelled;
|
bool cancelled;
|
||||||
std::list<MI_MOVIE_INFO> pending;
|
std::vector<MI_MOVIE_INFO> pending;
|
||||||
std::list<MI_MOVIE_INFO> done;
|
std::vector<MI_MOVIE_INFO> completed;
|
||||||
std::list<MI_MOVIE_INFO> failed;
|
std::vector<MI_MOVIE_INFO> failed;
|
||||||
OpenThreads::Mutex mutex;
|
OpenThreads::Mutex mutex;
|
||||||
bool download(MI_MOVIE_INFO *mi);
|
bool download(MI_MOVIE_INFO *mi);
|
||||||
std::string getName(MI_MOVIE_INFO *mi, std::string ext = "mp4");
|
std::string getName(MI_MOVIE_INFO *mi, std::string ext = "mp4");
|
||||||
@@ -53,10 +53,12 @@ class cYTCache
|
|||||||
bool useCachedCopy(MI_MOVIE_INFO *mi);
|
bool useCachedCopy(MI_MOVIE_INFO *mi);
|
||||||
bool addToCache(MI_MOVIE_INFO *mi);
|
bool addToCache(MI_MOVIE_INFO *mi);
|
||||||
void cancel(MI_MOVIE_INFO *mi);
|
void cancel(MI_MOVIE_INFO *mi);
|
||||||
|
void remove(MI_MOVIE_INFO *mi);
|
||||||
void cancelAll(void);
|
void cancelAll(void);
|
||||||
std::list<MI_MOVIE_INFO> getDone(bool clear = false);
|
std::vector<MI_MOVIE_INFO> getCompleted(void);
|
||||||
std::list<MI_MOVIE_INFO> getFailed(bool clear = false);
|
std::vector<MI_MOVIE_INFO> getFailed(void);
|
||||||
void clearDone(void);
|
std::vector<MI_MOVIE_INFO> getPending(void);
|
||||||
void clearFailed(void);
|
void clearCompleted(MI_MOVIE_INFO *mi = NULL);
|
||||||
|
void clearFailed(MI_MOVIE_INFO *mi = NULL);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@@ -70,7 +70,7 @@ std::string cYTVideoInfo::GetUrl(int *fmt, bool mandatory)
|
|||||||
fmt = &default_fmt;
|
fmt = &default_fmt;
|
||||||
|
|
||||||
yt_urlmap_iterator_t it;
|
yt_urlmap_iterator_t it;
|
||||||
if (*fmt) {
|
if (fmt) {
|
||||||
if ((it = formats.find(*fmt)) != formats.end()) {
|
if ((it = formats.find(*fmt)) != formats.end()) {
|
||||||
return it->second.GetUrl();
|
return it->second.GetUrl();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user