diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 74700bf24..100acd626 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1429,6 +1429,11 @@ moviebrowser.yt_most_responded Feeds mit den meisten Reaktionen moviebrowser.yt_most_shared Am häufigsten wiedergegebe Videos moviebrowser.yt_next_results Nächste Ergebnisse 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_prev_results Vorherige Ergebnisse moviebrowser.yt_recently_featured Vor kurzem empfohlen diff --git a/data/locale/english.locale b/data/locale/english.locale index 1767bd4fb..a70d08722 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1429,6 +1429,11 @@ moviebrowser.yt_most_responded Most responded moviebrowser.yt_most_shared Most shared moviebrowser.yt_next_results Next results 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_prev_results Previous results moviebrowser.yt_recently_featured Recently featured diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 43bf819a2..a53b55afe 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -606,6 +606,7 @@ void CMovieBrowser::initGlobalSettings(void) m_settings.browserRowWidth[5] = m_defaultRowWidth[m_settings.browserRowItem[5]]; //30; m_settings.ytmode = cYTFeedParser::MOST_POPULAR; + m_settings.ytorderby = cYTFeedParser::ORDERBY_PUBLISHED; m_settings.ytresults = 10; m_settings.ytregion = "default"; m_settings.ytquality = 37; @@ -772,6 +773,7 @@ bool CMovieBrowser::loadSettings(MB_SETTINGS* settings) settings->browserRowWidth[i] = configfile.getInt32(cfg_key, 50); } 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->ytquality = configfile.getInt32("mb_ytquality", 37); // itag value (MP4, 1080p) 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("mb_ytmode", settings->ytmode); + configfile.setInt32("mb_ytorderby", settings->ytorderby); configfile.setInt32("mb_ytresults", settings->ytresults); configfile.setInt32("mb_ytquality", settings->ytquality); 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); 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(); } else { //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)) +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 ret = LOCALE_MOVIEBROWSER_YT_MOST_POPULAR; @@ -3739,6 +3752,7 @@ bool CMovieBrowser::showYTMenu() std::string search = m_settings.ytsearch; 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 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); mainMenu.addItem(new CMenuForwarder(LOCALE_EVENTFINDER_START_SEARCH, true, NULL, selector, cnt, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE)); diff --git a/src/gui/moviebrowser.h b/src/gui/moviebrowser.h index 2486bf0e5..e543ee303 100644 --- a/src/gui/moviebrowser.h +++ b/src/gui/moviebrowser.h @@ -229,6 +229,7 @@ typedef struct MB_INFO_ITEM lastRecordRow[MB_MAX_ROWS]; int lastRecordRowWidth[MB_MAX_ROWS]; int ytmode; + int ytorderby; int ytresults; int ytquality; int ytconcconn; diff --git a/src/system/locals.h b/src/system/locals.h index 1fd8f82cb..1dc09f87c 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1456,6 +1456,11 @@ typedef enum LOCALE_MOVIEBROWSER_YT_MOST_SHARED, LOCALE_MOVIEBROWSER_YT_NEXT_RESULTS, 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_PREV_RESULTS, LOCALE_MOVIEBROWSER_YT_RECENTLY_FEATURED, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 18924eac2..214f61001 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1456,6 +1456,11 @@ const char * locale_real_names[] = "moviebrowser.yt_most_shared", "moviebrowser.yt_next_results", "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_prev_results", "moviebrowser.yt_recently_featured", diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index 7bdfc8535..5837f51fb 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -472,7 +472,7 @@ bool cYTFeedParser::ParseFeed(std::string &url) 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/"; 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 += search; url += "&"; + const char *orderby_values[] = { "published", "relevance", "viewCount", "rating" }; + url += "orderby=" + std::string(orderby_values[orderby & 3]) + "&"; } feedmode = mode; diff --git a/src/system/ytparser.h b/src/system/ytparser.h index fb97d65d1..5e4d6f12d 100644 --- a/src/system/ytparser.h +++ b/src/system/ytparser.h @@ -129,10 +129,17 @@ class cYTFeedParser SEARCH, MODE_LAST }; + enum yt_feed_orderby_t + { + ORDERBY_PUBLISHED = 0, + ORDERBY_RELEVANCE, + ORDERBY_VIEWCOUNT, + ORDERBY_RATING + }; 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 DownloadThumbnail(cYTVideoInfo &vinfo, CURL *_curl_handle = NULL); bool GetVideoUrls();