yt: make search order selectable

This commit is contained in:
martii
2013-10-06 12:11:20 +02:00
committed by Jacek Jendrzej
parent 60705383eb
commit fd5f9f118d
8 changed files with 47 additions and 3 deletions

View File

@@ -1429,6 +1429,11 @@ 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_orderby Sortierung nach
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_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

View File

@@ -1429,6 +1429,11 @@ 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_orderby Order by
moviebrowser.yt_orderby.published publishing date
moviebrowser.yt_orderby.rating rating
moviebrowser.yt_orderby.relevance relevance
moviebrowser.yt_orderby.viewcount view count
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

View File

@@ -606,6 +606,7 @@ void CMovieBrowser::initGlobalSettings(void)
m_settings.browserRowWidth[5] = m_defaultRowWidth[m_settings.browserRowItem[5]]; //30; m_settings.browserRowWidth[5] = m_defaultRowWidth[m_settings.browserRowItem[5]]; //30;
m_settings.ytmode = cYTFeedParser::MOST_POPULAR; m_settings.ytmode = cYTFeedParser::MOST_POPULAR;
m_settings.ytorderby = cYTFeedParser::ORDERBY_PUBLISHED;
m_settings.ytresults = 10; m_settings.ytresults = 10;
m_settings.ytregion = "default"; m_settings.ytregion = "default";
m_settings.ytquality = 37; m_settings.ytquality = 37;
@@ -772,6 +773,7 @@ bool CMovieBrowser::loadSettings(MB_SETTINGS* settings)
settings->browserRowWidth[i] = configfile.getInt32(cfg_key, 50); settings->browserRowWidth[i] = configfile.getInt32(cfg_key, 50);
} }
settings->ytmode = configfile.getInt32("mb_ytmode", cYTFeedParser::MOST_POPULAR); settings->ytmode = configfile.getInt32("mb_ytmode", cYTFeedParser::MOST_POPULAR);
settings->ytorderby = configfile.getInt32("mb_ytorderby", cYTFeedParser::ORDERBY_PUBLISHED);
settings->ytresults = configfile.getInt32("mb_ytresults", 10); settings->ytresults = configfile.getInt32("mb_ytresults", 10);
settings->ytquality = configfile.getInt32("mb_ytquality", 37); // itag value (MP4, 1080p) settings->ytquality = configfile.getInt32("mb_ytquality", 37); // itag value (MP4, 1080p)
settings->ytconcconn = configfile.getInt32("mb_ytconcconn", 4); // concurrent connections settings->ytconcconn = configfile.getInt32("mb_ytconcconn", 4); // concurrent connections
@@ -839,6 +841,7 @@ bool CMovieBrowser::saveSettings(MB_SETTINGS* settings)
configfile.setInt32(cfg_key, settings->browserRowWidth[i]); configfile.setInt32(cfg_key, settings->browserRowWidth[i]);
} }
configfile.setInt32("mb_ytmode", settings->ytmode); configfile.setInt32("mb_ytmode", settings->ytmode);
configfile.setInt32("mb_ytorderby", settings->ytorderby);
configfile.setInt32("mb_ytresults", settings->ytresults); configfile.setInt32("mb_ytresults", settings->ytresults);
configfile.setInt32("mb_ytquality", settings->ytquality); configfile.setInt32("mb_ytquality", settings->ytquality);
configfile.setInt32("mb_ytconcconn", settings->ytconcconn); configfile.setInt32("mb_ytconcconn", settings->ytconcconn);
@@ -3593,7 +3596,7 @@ void CMovieBrowser::loadYTitles(int mode, std::string search, std::string id)
ytparser.SetConcurrentDownloads(m_settings.ytconcconn); ytparser.SetConcurrentDownloads(m_settings.ytconcconn);
if (!ytparser.Parsed() || (ytparser.GetFeedMode() != mode)) { if (!ytparser.Parsed() || (ytparser.GetFeedMode() != mode)) {
if (ytparser.ParseFeed((cYTFeedParser::yt_feed_mode_t)mode, search, id)) { if (ytparser.ParseFeed((cYTFeedParser::yt_feed_mode_t)mode, search, id, (cYTFeedParser::yt_feed_orderby_t)m_settings.ytorderby)) {
ytparser.DownloadThumbnails(); ytparser.DownloadThumbnails();
} else { } else {
//FIXME show error //FIXME show error
@@ -3642,6 +3645,16 @@ const CMenuOptionChooser::keyval YT_FEED_OPTIONS[] =
#define YT_FEED_OPTION_COUNT (sizeof(YT_FEED_OPTIONS)/sizeof(CMenuOptionChooser::keyval)) #define YT_FEED_OPTION_COUNT (sizeof(YT_FEED_OPTIONS)/sizeof(CMenuOptionChooser::keyval))
const CMenuOptionChooser::keyval YT_ORDERBY_OPTIONS[] =
{
{ cYTFeedParser::ORDERBY_PUBLISHED, LOCALE_MOVIEBROWSER_YT_ORDERBY_PUBLISHED },
{ cYTFeedParser::ORDERBY_RELEVANCE, LOCALE_MOVIEBROWSER_YT_ORDERBY_RELEVANCE },
{ cYTFeedParser::ORDERBY_VIEWCOUNT, LOCALE_MOVIEBROWSER_YT_ORDERBY_VIEWCOUNT },
{ cYTFeedParser::ORDERBY_RATING, LOCALE_MOVIEBROWSER_YT_ORDERBY_RATING },
};
#define YT_ORDERBY_OPTION_COUNT (sizeof(YT_ORDERBY_OPTIONS)/sizeof(CMenuOptionChooser::keyval))
neutrino_locale_t CMovieBrowser::getFeedLocale(void) neutrino_locale_t CMovieBrowser::getFeedLocale(void)
{ {
neutrino_locale_t ret = LOCALE_MOVIEBROWSER_YT_MOST_POPULAR; neutrino_locale_t ret = LOCALE_MOVIEBROWSER_YT_MOST_POPULAR;
@@ -3739,6 +3752,7 @@ bool CMovieBrowser::showYTMenu()
std::string search = m_settings.ytsearch; std::string search = m_settings.ytsearch;
CStringInputSMS stringInput(LOCALE_MOVIEBROWSER_YT_SEARCH, &search, 20, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789 -_/()<>=+.,:!?\\'"); CStringInputSMS stringInput(LOCALE_MOVIEBROWSER_YT_SEARCH, &search, 20, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789 -_/()<>=+.,:!?\\'");
mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_SEARCH, true, search, &stringInput, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW)); mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_SEARCH, true, search, &stringInput, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW));
mainMenu.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_YT_ORDERBY, &m_settings.ytorderby, YT_ORDERBY_OPTIONS, YT_ORDERBY_OPTION_COUNT, true, NULL, CRCInput::RC_nokey, "", true));
sprintf(cnt, "%d", cYTFeedParser::SEARCH); sprintf(cnt, "%d", cYTFeedParser::SEARCH);
mainMenu.addItem(new CMenuForwarder(LOCALE_EVENTFINDER_START_SEARCH, true, NULL, selector, cnt, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE)); mainMenu.addItem(new CMenuForwarder(LOCALE_EVENTFINDER_START_SEARCH, true, NULL, selector, cnt, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE));

View File

@@ -229,6 +229,7 @@ typedef struct
MB_INFO_ITEM lastRecordRow[MB_MAX_ROWS]; MB_INFO_ITEM lastRecordRow[MB_MAX_ROWS];
int lastRecordRowWidth[MB_MAX_ROWS]; int lastRecordRowWidth[MB_MAX_ROWS];
int ytmode; int ytmode;
int ytorderby;
int ytresults; int ytresults;
int ytquality; int ytquality;
int ytconcconn; int ytconcconn;

View File

@@ -1456,6 +1456,11 @@ 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_ORDERBY,
LOCALE_MOVIEBROWSER_YT_ORDERBY_PUBLISHED,
LOCALE_MOVIEBROWSER_YT_ORDERBY_RATING,
LOCALE_MOVIEBROWSER_YT_ORDERBY_RELEVANCE,
LOCALE_MOVIEBROWSER_YT_ORDERBY_VIEWCOUNT,
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,

View File

@@ -1456,6 +1456,11 @@ 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_orderby",
"moviebrowser.yt_orderby.published",
"moviebrowser.yt_orderby.rating",
"moviebrowser.yt_orderby.relevance",
"moviebrowser.yt_orderby.viewcount",
"moviebrowser.yt_pref_quality", "moviebrowser.yt_pref_quality",
"moviebrowser.yt_prev_results", "moviebrowser.yt_prev_results",
"moviebrowser.yt_recently_featured", "moviebrowser.yt_recently_featured",

View File

@@ -472,7 +472,7 @@ bool cYTFeedParser::ParseFeed(std::string &url)
return parseFeedXml(answer); return parseFeedXml(answer);
} }
bool cYTFeedParser::ParseFeed(yt_feed_mode_t mode, std::string search, std::string vid) bool cYTFeedParser::ParseFeed(yt_feed_mode_t mode, std::string search, std::string vid, yt_feed_orderby_t orderby)
{ {
std::string url = "http://gdata.youtube.com/feeds/api/standardfeeds/"; std::string url = "http://gdata.youtube.com/feeds/api/standardfeeds/";
bool append_res = true; bool append_res = true;
@@ -540,6 +540,8 @@ bool cYTFeedParser::ParseFeed(yt_feed_mode_t mode, std::string search, std::stri
url = "http://gdata.youtube.com/feeds/api/videos?q="; url = "http://gdata.youtube.com/feeds/api/videos?q=";
url += search; url += search;
url += "&"; url += "&";
const char *orderby_values[] = { "published", "relevance", "viewCount", "rating" };
url += "orderby=" + std::string(orderby_values[orderby & 3]) + "&";
} }
feedmode = mode; feedmode = mode;

View File

@@ -129,10 +129,17 @@ class cYTFeedParser
SEARCH, SEARCH,
MODE_LAST MODE_LAST
}; };
enum yt_feed_orderby_t
{
ORDERBY_PUBLISHED = 0,
ORDERBY_RELEVANCE,
ORDERBY_VIEWCOUNT,
ORDERBY_RATING
};
cYTFeedParser(); cYTFeedParser();
~cYTFeedParser(); ~cYTFeedParser();
bool ParseFeed(yt_feed_mode_t mode = MOST_POPULAR, std::string search = "", std::string vid = ""); bool ParseFeed(yt_feed_mode_t mode = MOST_POPULAR, std::string search = "", std::string vid = "", yt_feed_orderby_t orderby = ORDERBY_PUBLISHED);
bool ParseVideoInfo(cYTVideoInfo &vinfo, CURL *_curl_handle = NULL); bool ParseVideoInfo(cYTVideoInfo &vinfo, CURL *_curl_handle = NULL);
bool DownloadThumbnail(cYTVideoInfo &vinfo, CURL *_curl_handle = NULL); bool DownloadThumbnail(cYTVideoInfo &vinfo, CURL *_curl_handle = NULL);
bool GetVideoUrls(); bool GetVideoUrls();