ytparser/moviebrowser: add option for selecting prefered quality

This commit is contained in:
martii
2013-06-09 09:31:57 +02:00
committed by [CST] Focus
parent 0e6848d7d9
commit e01e96c1ac
8 changed files with 34 additions and 7 deletions

View File

@@ -1368,6 +1368,7 @@ moviebrowser.yt_most_responded Feeds mit den meisten Reaktionen
moviebrowser.yt_most_shared Am häufigsten wiedergegebe Videos moviebrowser.yt_most_shared Am häufigsten wiedergegebe Videos
moviebrowser.yt_next_results Nächste Ergebnisse moviebrowser.yt_next_results Nächste Ergebnisse
moviebrowser.yt_on_the_web Trendvideos moviebrowser.yt_on_the_web Trendvideos
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
moviebrowser.yt_region Region moviebrowser.yt_region Region

View File

@@ -1368,6 +1368,7 @@ moviebrowser.yt_most_responded Most responded
moviebrowser.yt_most_shared Most shared moviebrowser.yt_most_shared Most shared
moviebrowser.yt_next_results Next results moviebrowser.yt_next_results Next results
moviebrowser.yt_on_the_web Trending videos moviebrowser.yt_on_the_web Trending videos
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
moviebrowser.yt_region Region moviebrowser.yt_region Region

View File

@@ -772,6 +772,7 @@ bool CMovieBrowser::loadSettings(MB_SETTINGS* settings)
} }
settings->ytmode = configfile.getInt32("mb_ytmode", cYTFeedParser::MOST_POPULAR); settings->ytmode = configfile.getInt32("mb_ytmode", cYTFeedParser::MOST_POPULAR);
settings->ytresults = configfile.getInt32("mb_ytresults", 10); settings->ytresults = configfile.getInt32("mb_ytresults", 10);
settings->ytquality = configfile.getInt32("mb_ytquality", 22); // itag value (MP4, 720p)
settings->ytregion = configfile.getString("mb_ytregion", "default"); settings->ytregion = configfile.getString("mb_ytregion", "default");
settings->ytsearch = configfile.getString("mb_ytsearch", ""); settings->ytsearch = configfile.getString("mb_ytsearch", "");
settings->ytvid = configfile.getString("mb_ytvid", ""); settings->ytvid = configfile.getString("mb_ytvid", "");
@@ -826,6 +827,7 @@ bool CMovieBrowser::saveSettings(MB_SETTINGS* settings)
} }
configfile.setInt32("mb_ytmode", settings->ytmode); configfile.setInt32("mb_ytmode", settings->ytmode);
configfile.setInt32("mb_ytresults", settings->ytresults); configfile.setInt32("mb_ytresults", settings->ytresults);
configfile.setInt32("mb_ytquality", settings->ytquality);
configfile.setString("mb_ytregion", settings->ytregion); configfile.setString("mb_ytregion", settings->ytregion);
configfile.setString("mb_ytsearch", settings->ytsearch); configfile.setString("mb_ytsearch", settings->ytsearch);
configfile.setString("mb_ytvid", settings->ytvid); configfile.setString("mb_ytvid", settings->ytvid);
@@ -3587,7 +3589,7 @@ void CMovieBrowser::loadYTitles(int mode, std::string search, std::string id)
movieInfo.ytid = ylist[i].id; movieInfo.ytid = ylist[i].id;
movieInfo.file.Name = ylist[i].title; movieInfo.file.Name = ylist[i].title;
movieInfo.file.Url = ylist[i].GetUrl(); movieInfo.file.Url = ylist[i].GetUrl(m_settings.ytquality, false);
m_vMovieInfo.push_back(movieInfo); m_vMovieInfo.push_back(movieInfo);
} }
m_currentBrowserSelection = 0; m_currentBrowserSelection = 0;
@@ -3681,6 +3683,19 @@ bool CMovieBrowser::showYTMenu()
region->addOption("US"); region->addOption("US");
mainMenu.addItem(region); mainMenu.addItem(region);
#define YT_QUALITY_OPTION_COUNT 3
CMenuOptionChooser::keyval_ext YT_QUALITY_OPTIONS[YT_QUALITY_OPTION_COUNT] =
{
{ 18, NONEXISTANT_LOCALE, "MP4 270p/360p"},
{ 22, NONEXISTANT_LOCALE, "MP4 720p" },
#if 0
{ 34, NONEXISTANT_LOCALE, "FLV 360p" },
{ 35, NONEXISTANT_LOCALE, "FLV 480p" },
#endif
{ 37, NONEXISTANT_LOCALE, "MP4 1080p" }
};
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.exec(NULL, ""); mainMenu.exec(NULL, "");
delete selector; delete selector;

View File

@@ -229,6 +229,7 @@ typedef struct
int lastRecordRowWidth[MB_MAX_ROWS]; int lastRecordRowWidth[MB_MAX_ROWS];
int ytmode; int ytmode;
int ytresults; int ytresults;
int ytquality;
std::string ytregion; std::string ytregion;
std::string ytvid; std::string ytvid;
std::string ytsearch; std::string ytsearch;

View File

@@ -1395,6 +1395,7 @@ typedef enum
LOCALE_MOVIEBROWSER_YT_MOST_SHARED, LOCALE_MOVIEBROWSER_YT_MOST_SHARED,
LOCALE_MOVIEBROWSER_YT_NEXT_RESULTS, LOCALE_MOVIEBROWSER_YT_NEXT_RESULTS,
LOCALE_MOVIEBROWSER_YT_ON_THE_WEB, LOCALE_MOVIEBROWSER_YT_ON_THE_WEB,
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,
LOCALE_MOVIEBROWSER_YT_REGION, LOCALE_MOVIEBROWSER_YT_REGION,

View File

@@ -1395,6 +1395,7 @@ const char * locale_real_names[] =
"moviebrowser.yt_most_shared", "moviebrowser.yt_most_shared",
"moviebrowser.yt_next_results", "moviebrowser.yt_next_results",
"moviebrowser.yt_on_the_web", "moviebrowser.yt_on_the_web",
"moviebrowser.yt_pref_quality",
"moviebrowser.yt_prev_results", "moviebrowser.yt_prev_results",
"moviebrowser.yt_recently_featured", "moviebrowser.yt_recently_featured",
"moviebrowser.yt_region", "moviebrowser.yt_region",

View File

@@ -59,19 +59,26 @@ void cYTVideoInfo::Dump()
printf("===================================================================\n"); printf("===================================================================\n");
} }
std::string cYTVideoInfo::GetUrl(int fmt) std::string cYTVideoInfo::GetUrl(int fmt, bool mandatory)
{ {
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();
if (mandatory)
return ""; return "";
} }
if ((it = formats.find(22)) != formats.end()) // 720p if ((it = formats.find(22)) != formats.end()) // 720p MP4
return it->second.GetUrl(); return it->second.GetUrl();
if ((it = formats.find(37)) != formats.end()) // 1080p #if 0
if ((it = formats.find(35)) != formats.end()) // 480p FLV
return it->second.GetUrl(); return it->second.GetUrl();
if ((it = formats.find(18)) != formats.end()) // 270p/360p if ((it = formats.find(34)) != formats.end()) // 360p FLV
return it->second.GetUrl();
#endif
if ((it = formats.find(18)) != formats.end()) // 270p/360p MP4
return it->second.GetUrl();
if ((it = formats.find(37)) != formats.end()) // 1080p MP4
return it->second.GetUrl(); return it->second.GetUrl();
return ""; return "";
} }

View File

@@ -58,7 +58,7 @@ class cYTVideoInfo
yt_urlmap_t formats; yt_urlmap_t formats;
void Dump(); void Dump();
std::string GetUrl(int fmt = 0); std::string GetUrl(int fmt = 0, bool mandatory = true);
}; };