diff --git a/acinclude.m4 b/acinclude.m4 index a90ad03e0..8ddbab68b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -75,32 +75,6 @@ if test "$enable_omdb_key_manage" = "yes" ; then fi # omdb end -# youtube -AC_ARG_WITH(youtube-dev-key, - AS_HELP_STRING([--with-youtube-dev-key=KEY], [API dev key for YouTube streaming]), - [YT_DEV_KEY="$withval"], - [YT_DEV_KEY=""]) -AC_DEFINE_UNQUOTED([YT_DEV_KEY], ["$YT_DEV_KEY"], [API dev key for YouTube streaming]) - -AC_ARG_ENABLE([youtube-key-manage], - AS_HELP_STRING([--enable-youtube-key-manage], [Enable manage YouTube dev key via gui @<:@default=yes@:>@]), - [enable_youtube_key_manage="$enableval"], - [enable_youtube_key_manage="yes"]) - -if test "$enable_youtube_key_manage" = "yes" ; then - AC_DEFINE([ENABLE_YOUTUBE_KEY_MANAGE], 1, [Enable manage YouTube dev key via gui]) -fi - -AC_ARG_ENABLE([youtube-player], - AS_HELP_STRING([--enable-youtube-player], [Enable play and control youtube streams with moviebrowser @<:@default=yes@:>@]), - [enable_youtube_player="$enableval"], - [enable_youtube_player="yes"]) - -if test "$enable_youtube_player" = "yes" ; then - AC_DEFINE([ENABLE_YOUTUBE_PLAYER], 1, [Enable play and control YouTube streams with moviebrowser]) -fi -# youtube end - # shoutcast AC_ARG_WITH(shoutcast-dev-key, AS_HELP_STRING([--with-shoutcast-dev-key=KEY], [API dev key to get stream data lists from ShoutCast service]), @@ -118,6 +92,23 @@ if test "$enable_shoutcast_key_manage" = "yes" ; then fi # shoutcast end +# youtube +AC_ARG_WITH(youtube-dev-key, + AS_HELP_STRING([--with-youtube-dev-key=KEY], [API dev key for YouTube streaming]), + [YOUTUBE_DEV_KEY="$withval"], + [YOUTUBE_DEV_KEY=""]) +AC_DEFINE_UNQUOTED([YOUTUBE_DEV_KEY], ["$YOUTUBE_DEV_KEY"], [API dev key for YouTube streaming]) + +AC_ARG_ENABLE([youtube-key-manage], + AS_HELP_STRING([--enable-youtube-key-manage], [Enable manage YouTube dev key via gui @<:@default=yes@:>@]), + [enable_youtube_key_manage="$enableval"], + [enable_youtube_key_manage="yes"]) + +if test "$enable_youtube_key_manage" = "yes" ; then + AC_DEFINE([ENABLE_YOUTUBE_KEY_MANAGE], 1, [Enable manage YouTube dev key via gui]) +fi +# youtube end + AC_ARG_WITH(libcoolstream-static-dir, AS_HELP_STRING([--with-libcoolstream-static-dir=PATH], [path for static libcoolstream [[NONE]]]), [LIBCOOLSTREAM_STATIC_DIR="$withval"], diff --git a/data/icons/headers/Makefile.am b/data/icons/headers/Makefile.am index 23f91167e..3b669ca10 100644 --- a/data/icons/headers/Makefile.am +++ b/data/icons/headers/Makefile.am @@ -33,5 +33,4 @@ install_DATA = \ streaming.png \ timer.png \ upnp.png \ - video.png \ - ytplay.png + video.png \ No newline at end of file diff --git a/data/icons/headers/ytplay.png b/data/icons/headers/ytplay.png deleted file mode 100644 index 8d3168243..000000000 Binary files a/data/icons/headers/ytplay.png and /dev/null differ diff --git a/data/icons/hints/Makefile.am b/data/icons/hints/Makefile.am index 241c67112..9eb7e4390 100644 --- a/data/icons/hints/Makefile.am +++ b/data/icons/hints/Makefile.am @@ -64,8 +64,7 @@ install_DATA = \ hint_vtxt.png \ hint_webradio.png \ hint_webtv.png \ - hint_xmltv.png \ - hint_ytplay.png + hint_xmltv.png if ENABLE_PIP install_DATA += \ diff --git a/data/icons/hints/hint_ytplay.png b/data/icons/hints/hint_ytplay.png deleted file mode 100644 index 391fd7512..000000000 Binary files a/data/icons/hints/hint_ytplay.png and /dev/null differ diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 5fc85c41f..9d48e5622 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1624,7 +1624,7 @@ menu.hint_misc_energy Energieverbrauchs- und Standby-Optionen, verzögertes Auss menu.hint_misc_epg Diverse EPG-Einstellungen und Speicherverzeichnis für EPG-Daten menu.hint_misc_filebrowser Dateisystem, Dateirechte anzeigen im Dateibrowser, Startverzeichnisoptionen menu.hint_misc_general Standby-, Videotext- und Debuglevel-Einstellungen -menu.hint_misc_onlineservices Konfigurieren und steuern von Online-Diensten wie Wetter, YouTube, SHOUTCast und TMDb +menu.hint_misc_onlineservices Konfigurieren und steuern von Online-Diensten wie Wetter, TMDb, IMDb, SHOUTCast und YouTube menu.hint_misc_zapit Verwaltung der Start-Kanäle für den TV/Radio-Modus menu.hint_movie Wiedergabe von Filmen menu.hint_moviebrowser_fonts Ändern Sie die Schriftgrößen im Moviebrowser (Meine Aufnahmen) @@ -1948,9 +1948,7 @@ menu.hint_webtv_xml_auto Lädt automatisch alle WebTV-Dateien aus %s/ und %s/ menu.hint_window_size Kanalliste, EPG-Infos und einige andere Fenster werden mit diesem Faktor skaliert menu.hint_xmltv_setup Hier konfigurieren Sie XMLTV-Dateien, die EPG-Daten enthalten menu.hint_youtube_dev_id Geben Sie die YouTube Dev ID ein. Eine leere Eingabe schaltet die YouTube-Unterstützung aus -menu.hint_youtube_enabled Schaltet die YouTube-Unterstützung ein oder aus -menu.hint_ytplay Wiedergabe von ausgewählten YouTube Feeds -menu.hint_ytplay_setup Konfigurieren Sie YouTube-spezifische Optionen wie maximale Ergebnisse bei Suchen oder Cache-Verzeichnis +menu.hint_youtube_enabled Schaltet die YouTube-Unterstützung (für Plugins) ein oder aus menu.hint_zap_cycle Wählen Sie, ob nur innerhalb des aktiven Bouquets umgeschaltet werden kann menu.next Weiter message.frame_enable Rahmen für Meldungen und Hinweisfenster @@ -2246,7 +2244,6 @@ moviebrowser.option_browser Anzeigeoptionen moviebrowser.reload_at_start Filminfos neu laden bei Start moviebrowser.remount_at_start Filmdepot verbinden bei Start moviebrowser.scan_for_movies Suche Aufnahmen ... -moviebrowser.scan_for_videos Suche YT-Videos ... moviebrowser.serie_auto_create Serien automatisch zuordnen moviebrowser.serie_head Serie moviebrowser.serie_name Name ändern @@ -2285,31 +2282,6 @@ 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_dl_dir Youtube download Verzeichnis -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 -moviebrowser.yt_most_popular Beliebteste Videos heute -moviebrowser.yt_most_popular_all_time Beliebteste Videos -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_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 moviecut.cancel Bearbeiten des Filmes abbrechen? movieplayer.bisection_jump Bisektionale Sprünge movieplayer.bookmark Bookmarks @@ -2342,7 +2314,6 @@ movieplayer.timeosd_while_searching Zeige Spielzeit während des Spulens movieplayer.titles Titel movieplayer.toomanybookmarks Sie haben bereits zu viele Lesezeichen angelegt.\nEs muß erst ein anderes gelöscht werden. movieplayer.tsplayback TS Abspielen -movieplayer.ytplayback YouTube-Feed Wiedergabe movieplayer.zap Umschalten während der Film- oder Timeshift-Wiedergabe nicht möglich mpkey.audio Tonspuren mpkey.bookmark Markierungen @@ -3130,7 +3101,7 @@ xmltv.xml.del Entfernen xmltv.xml.enter Eintragen xmltv.xml.reload Neu laden youtube.dev_id YouTube Dev ID -youtube.enabled YouTube-Unterstützung +youtube.enabled YouTube-Unterstützung (für Plugins) zapit.scantype Service-Auswahl zapit.scantype.all Alle Services zapit.scantype.radio Nur Radio diff --git a/data/locale/english.locale b/data/locale/english.locale index 0f1f7ab6d..2a678cee3 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1621,7 +1621,7 @@ menu.hint_misc_energy Enable soft-standby, delayed shutdown\ninactivity timers menu.hint_misc_epg Save/load EPG options, EPG cache options\nEPG save directory menu.hint_misc_filebrowser Filesystem encoding, file rights\ndeny directory leave menu.hint_misc_general Standby-, teletext- and debuglevel-settings -menu.hint_misc_onlineservices Configure and control online services like Weather, YouTube, SHOUTCast and TMDb +menu.hint_misc_onlineservices Configure and control online services like Weather, TMDb, IMDb, SHOUTCast and YouTube menu.hint_misc_zapit Initial TV/Radio channels menu.hint_movie Play movies menu.hint_moviebrowser_fonts Change moviebrowser (My recordings) font sizes @@ -1945,9 +1945,7 @@ menu.hint_webtv_xml_auto Auto-load all existing WebTV files from %s/ and %s/ menu.hint_window_size Channellist, EPG-infos and some other windows are scaled by this factor menu.hint_xmltv_setup Configure XMLTV files with EPG data to describe TV listings menu.hint_youtube_dev_id Type your YouTube Dev ID. An empty input disables YouTube support -menu.hint_youtube_enabled Enable or disable YouTube support -menu.hint_ytplay Play selected YouTube feeds -menu.hint_ytplay_setup Configure YouTube-specific options, e.g. an upper limit for search results +menu.hint_youtube_enabled Enable or disable YouTube support (for plugins) menu.hint_zap_cycle When swithing channels, stay in current bouquet menu.next Next message.frame_enable Message and hint box frames @@ -2243,7 +2241,6 @@ moviebrowser.option_browser Browser Options moviebrowser.reload_at_start Reload movie info at start moviebrowser.remount_at_start Remount at start moviebrowser.scan_for_movies Scan for recordings... -moviebrowser.scan_for_videos Scan for YT-Videos ... moviebrowser.serie_auto_create Serie auto create moviebrowser.serie_head Serie moviebrowser.serie_name Change name @@ -2282,31 +2279,6 @@ 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_dl_dir YouTube download directory -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 -moviebrowser.yt_most_popular Most popular today -moviebrowser.yt_most_popular_all_time Most popular -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_pending Pending downloads -moviebrowser.yt_pref_quality Prefered quality -moviebrowser.yt_region Region -moviebrowser.yt_related Related videos -moviebrowser.yt_search Search keyword moviecut.cancel Cancel movie editing? movieplayer.bisection_jump Bisectional jumps movieplayer.bookmark Bookmarks @@ -2339,7 +2311,6 @@ movieplayer.timeosd_while_searching Show playtime while searching movieplayer.titles Titles movieplayer.toomanybookmarks There are too many bookmarks.\nYou need to delete one of them first. movieplayer.tsplayback Play TS -movieplayer.ytplayback YouTube videoplayer movieplayer.zap Zap not possible while movie or timeshift playback mpkey.audio Audiotracks mpkey.bookmark Bookmarks @@ -3125,7 +3096,7 @@ xmltv.xml.del Remove xmltv.xml.enter Enter xmltv.xml.reload Reload youtube.dev_id YouTube Dev ID -youtube.enabled YouTube support +youtube.enabled YouTube support (for plugins) zapit.scantype scan for services zapit.scantype.all all services zapit.scantype.radio only radio diff --git a/data/locale/nederlands.locale b/data/locale/nederlands.locale index 3cc64278d..714390dab 100644 --- a/data/locale/nederlands.locale +++ b/data/locale/nederlands.locale @@ -1344,7 +1344,6 @@ menu.hint_volume_pos Selecteer positie volume indicator menu.hint_volume_size Selecteer volume indicator hoogte menu.hint_webtv_setup Hier geconfigureerde WebTV-zenders zijn in de standaard zenderlijsten zichtbaar. menu.hint_window_size Zenderlijst, EPG-infos en andere venster worden op deze factor geschaald -menu.hint_ytplay Video's afspelen van de populaire video website Youtube menu.hint_zap_cycle Tijdens het schakelen tussen kanalen in huidige favorieten lijst menu.next Volgende (Druk op menu om af te sluiten) messagebox.back Terug @@ -1575,7 +1574,6 @@ moviebrowser.option_browser Browser Opties moviebrowser.reload_at_start Herlaad film informatie bij het starten moviebrowser.remount_at_start Herkoppelen bij het starten moviebrowser.scan_for_movies Films scannen ... -moviebrowser.scan_for_videos YT-Videos scannen ... moviebrowser.serie_auto_create Series automatisch maken moviebrowser.serie_head Serie moviebrowser.serie_name Verander naam @@ -1608,30 +1606,6 @@ moviebrowser.update_if_dest_empty_only Kopieer indien doelbestemming leeg is moviebrowser.use_dir Gebruik directory moviebrowser.use_movie_dir Gebruik film directory moviebrowser.use_rec_dir Gebruik opname directory -moviebrowser.yt_cache Downloads -moviebrowser.yt_cache_add Download of\n%s\nis scheduled. -moviebrowser.yt_cancel Alles stoppen -moviebrowser.yt_cancel_transfer Download stoppen? -moviebrowser.yt_clear Clear -moviebrowser.yt_completed Volledige downloads -moviebrowser.yt_concurrent_connections Concurrent connecties -moviebrowser.yt_error Laden van youtube video mislukt -moviebrowser.yt_failed Downloads mislukt -moviebrowser.yt_history Zoekgeschiedenis -moviebrowser.yt_max_history Maximale zoekgeschiedenis grootte -moviebrowser.yt_max_results Maximaal aantal resultaten -moviebrowser.yt_most_popular Meest populair -moviebrowser.yt_most_popular_all_time Meest populair -moviebrowser.yt_orderby Sorteren op -moviebrowser.yt_orderby.published Datum gepubiceerd -moviebrowser.yt_orderby.rating rating -moviebrowser.yt_orderby.relevance relevantie -moviebrowser.yt_orderby.viewcount weergave teller -moviebrowser.yt_pending Lopende downloads -moviebrowser.yt_pref_quality Gewenste kwaliteit -moviebrowser.yt_region Regio -moviebrowser.yt_related Gerelateerde video's -moviebrowser.yt_search Trefwoord movieplayer.bookmark Markeerpunten movieplayer.bookmarkname Naam markeerpunt movieplayer.bookmarkname_hint1 Nieuwe markeerpunt @@ -1656,7 +1630,6 @@ movieplayer.tshelp7 Ongeveer 1 minuut overslaan movieplayer.tshelp8 Ongeveer 5 minuten terug movieplayer.tshelp9 Ongeveer 5 minuten overslaan movieplayer.tsplayback Opname afspelen -movieplayer.ytplayback Youtube video's mpkey.audio Audio track mpkey.bookmark Markeerpunt opslaan mpkey.forward Vooruit diff --git a/data/locale/slovak.locale b/data/locale/slovak.locale index 971c1e06e..92a40ea09 100644 --- a/data/locale/slovak.locale +++ b/data/locale/slovak.locale @@ -1282,7 +1282,7 @@ mbkey.cut Vystrihnúť film mbkey.truncate Skrátiť film menu.back Späť menu.cancel Zrušiť -menu.hint_a_pic Nastavenie prehrávača hudby, prehliadača obrázkov, WebTV, TS, YouTube +menu.hint_a_pic Nastavenie prehrávača hudby, prehliadača obrázkov, WebTV, TS menu.hint_adzap Automatické prepnutie prepne späť na aktuálny kanál ak uplynie zvolený čas menu.hint_adzap_active Automatické prepnutie je aktívne. Novým prepnutím bude deaktivované. menu.hint_adzap_writedata Zapísanie dát na základe stavu funkcie automatického prepnutia do priečinka /tmp/adzap.data @@ -1569,7 +1569,7 @@ menu.hint_misc_energy Použitie pohotovostného režimu, oneskorené vypnutie\n menu.hint_misc_epg Voľby uloženia/načítania EPG, voľby ukladania EPG,\nEPG priečinok uloženia menu.hint_misc_filebrowser Kódovanie súborového systemu, oprávnenia súboru,\nzákaz odstrániť priečinok menu.hint_misc_general Spustenie do pohotovostného režimu, vyrovnávacia pamäť teletextu, hdd priečinok doplnkov,\núroveň debugovania -menu.hint_misc_onlineservices Konfigurácia a riadenie živých služieb ako YouTube, SHOUTcast a TMDb +menu.hint_misc_onlineservices Konfigurácia a riadenie živých služieb ako TMDb, IMDb, SHOUTcast a YouTube menu.hint_misc_zapit Východzie TV/Radio kanály menu.hint_movie Prehrávanie filmov menu.hint_moviebrowser_fonts Zmena veľkosti písma prehrávača filmov (Moje nahrávky) @@ -1890,8 +1890,6 @@ menu.hint_window_size Zoznam kanálov, EPG-Infp a niektoré iné okná sú zmen menu.hint_xmltv_setup Nakonfigurujte súbory XMLTV s údajmi EPG na opis televíznych zoznamov menu.hint_youtube_dev_id Zadajte vaše YouTube Dev ID. Prázdne zadanie zabranuje podpore YouTube menu.hint_youtube_enabled Povolenie alebo zakázanie podpory YouTube -menu.hint_ytplay Prehrávanie vybraných YouTube videí -menu.hint_ytplay_setup Konfigurácia špecifických volieb YouTube, napr. horný limit výsledkov vyhľadávania menu.hint_zap_cycle Pri prepínaní kanálov zotrvať v aktuálnom bukete menu.next Ďalej message.frame_enable Rámiky pre správy a informačné okná @@ -2186,7 +2184,6 @@ moviebrowser.option_browser Možnosti prehliadača moviebrowser.reload_at_start Načítanie informácie o filme pri štarte moviebrowser.remount_at_start Pripojiť pri štarte moviebrowser.scan_for_movies Hľadať pre filmy ... -moviebrowser.scan_for_videos Hľadať pre YT-videá ... moviebrowser.serie_auto_create Automaticky doplniť seriály moviebrowser.serie_head Seriály moviebrowser.serie_name Zmena názvu @@ -2225,31 +2222,6 @@ moviebrowser.update_if_dest_empty_only Kopírovať len ak je cieľové miesto pr moviebrowser.use_dir Použiť priečinok moviebrowser.use_movie_dir Použiť priečinok filmov moviebrowser.use_rec_dir Použiť priečinok nahrávania -moviebrowser.yt_cache Stiahnuté -moviebrowser.yt_cache_add Plánované \n%s\nsťahovanie. -moviebrowser.yt_cancel Zrušiť všetko -moviebrowser.yt_cancel_transfer Zrušiť sťahovanie? -moviebrowser.yt_clear Vyčistiť -moviebrowser.yt_completed Sťahovania ukončené -moviebrowser.yt_concurrent_connections Súbežné spojenia -moviebrowser.yt_dl_dir Adresár pre stiahnutie z YouTube -moviebrowser.yt_error Chyba načítania youtube videa -moviebrowser.yt_failed Chybné sťahovania -moviebrowser.yt_history Hľadať históriu -moviebrowser.yt_max_history Maximálna veľkosť hľadania histórie -moviebrowser.yt_max_results Maximálny počet výsledkov -moviebrowser.yt_most_popular Najpopulárnejšie dnes -moviebrowser.yt_most_popular_all_time Najpopulárnejšie -moviebrowser.yt_orderby Triediť podľa -moviebrowser.yt_orderby.published dátum zverejnenia -moviebrowser.yt_orderby.rating obľúbenosť -moviebrowser.yt_orderby.relevance závažnosť -moviebrowser.yt_orderby.viewcount sledovanosť -moviebrowser.yt_pending Čakajúce sťahovania -moviebrowser.yt_pref_quality Preferovaná kvalita -moviebrowser.yt_region Región -moviebrowser.yt_related Podobné videá -moviebrowser.yt_search Hľadať slovo moviecut.cancel Zrušiť úpravu filmu? movieplayer.bisection_jump Deliace skoky movieplayer.bookmark Záložky @@ -2282,7 +2254,6 @@ movieplayer.timeosd_while_searching Zobraziť čas pri vyhľadávaní movieplayer.titles Tituly movieplayer.toomanybookmarks Veľa záložiek.\nJe potrebné vymazať jednu najprv. movieplayer.tsplayback Prehrať TS -movieplayer.ytplayback YouTube prehrávač movieplayer.zap Prepnutie nie je možné počas prehrávania videa alebo časového posunu mpkey.audio Zvukové stopy mpkey.bookmark Záložky diff --git a/src/driver/movieinfo.cpp b/src/driver/movieinfo.cpp index 4ea268cb5..6f2f3cf9d 100644 --- a/src/driver/movieinfo.cpp +++ b/src/driver/movieinfo.cpp @@ -529,8 +529,6 @@ void CMovieInfo::clearMovieInfo(MI_MOVIE_INFO * movie_info) movie_info->bookmarks.user[i].name = ""; } movie_info->tfile.clear(); - movie_info->ytdate.clear(); - movie_info->ytid.clear(); } void MI_MOVIE_INFO::clear(void) @@ -576,10 +574,6 @@ void MI_MOVIE_INFO::clear(void) } tfile = ""; - ytdate = ""; - ytid = ""; - ytitag = 0; - marked = false; delAsk = true; source = UNKNOWN; diff --git a/src/driver/movieinfo.h b/src/driver/movieinfo.h index 49e7e2deb..5fa9e4870 100644 --- a/src/driver/movieinfo.h +++ b/src/driver/movieinfo.h @@ -149,13 +149,8 @@ class MI_MOVIE_INFO //MI_MOVIE_INFO &operator=(const MI_MOVIE_INFO& src); std::string tfile; // thumbnail/cover file name - std::string ytdate; // youtube published - std::string ytid; // youtube published - int ytitag; // youtube quality profile - enum miSource { UNKNOWN = 0, - YT, NK }; miSource source; diff --git a/src/gui/mediaplayer.cpp b/src/gui/mediaplayer.cpp index 582c2fdd2..0f834f830 100644 --- a/src/gui/mediaplayer.cpp +++ b/src/gui/mediaplayer.cpp @@ -177,12 +177,6 @@ int CMediaPlayerMenu::initMenuMedia(CMenuWidget *m, CPersonalizeGui *p) personalize->addItem(movieplayer_menu, fw_fileplay_audio, &g_settings.personalize[SNeutrinoSettings::P_MPLAYER_FILEPLAY_AUDIO]); #endif -#if ENABLE_YOUTUBE_PLAYER - // ytplayback - CMenuForwarder *fw_ytplay = new CMenuForwarder(LOCALE_MOVIEPLAYER_YTPLAYBACK, g_settings.youtube_enabled, NULL, &CMoviePlayerGui::getInstance(), "ytplayback", CRCInput::RC_blue); - fw_ytplay->setHint(NEUTRINO_ICON_HINT_YTPLAY, LOCALE_MENU_HINT_YTPLAY); - personalize->addItem(movieplayer_menu, fw_ytplay, &g_settings.personalize[SNeutrinoSettings::P_MPLAYER_YTPLAY]); -#endif // add movieplayer submenu CMenuForwarder *fw_mp = new CMenuForwarder(LOCALE_MAINMENU_MEDIAPLAYER, enabled, NULL, movieplayer_menu, NULL, CRCInput::RC_yellow); fw_mp->setHint(NEUTRINO_ICON_HINT_MOVIE, LOCALE_MENU_HINT_MOVIE); diff --git a/src/gui/mediaplayer_setup.cpp b/src/gui/mediaplayer_setup.cpp index c3dd2723c..90ee87139 100644 --- a/src/gui/mediaplayer_setup.cpp +++ b/src/gui/mediaplayer_setup.cpp @@ -122,12 +122,6 @@ int CMediaPlayerSetup::showMediaPlayerSetup() mf->setHint(NEUTRINO_ICON_HINT_MB, LOCALE_MENU_HINT_MOVIEBROWSER_SETUP); mediaSetup->addItem(mf); -#if ENABLE_YOUTUBE_PLAYER - mf = new CMenuForwarder(LOCALE_MOVIEPLAYER_YTPLAYBACK, true, NULL, &msetup, "show_ytmenu", CRCInput::convertDigitToKey(shortcut++)); - mf->setHint(NEUTRINO_ICON_HINT_YTPLAY, LOCALE_MENU_HINT_YTPLAY_SETUP); - mediaSetup->addItem(mf); -#endif - mediaSetup->addItem(GenericMenuSeparator); CMenuOptionChooser *mc; diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index 0dab7bea2..e601e9a08 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -673,21 +673,6 @@ int CMiscMenue::showMiscSettingsMenuOnlineServices() ms_oservices->addItem(GenericMenuSeparator); - // youtube - youtube_onoff = new CMenuOptionChooser(LOCALE_YOUTUBE_ENABLED, &g_settings.youtube_enabled, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, CApiKey::check_youtube_dev_id()); - youtube_onoff->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_YOUTUBE_ENABLED); - ms_oservices->addItem(youtube_onoff); - -#if ENABLE_YOUTUBE_KEY_MANAGE - changeNotify(LOCALE_YOUTUBE_DEV_ID, NULL); - CKeyboardInput youtube_dev_id_input(LOCALE_YOUTUBE_DEV_ID, &g_settings.youtube_dev_id, 39, this); - CMenuForwarder *mf_yt = new CMenuForwarder(LOCALE_YOUTUBE_DEV_ID, true, youtube_dev_id_short, &youtube_dev_id_input); - mf_yt->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_YOUTUBE_DEV_ID); - ms_oservices->addItem(mf_yt); -#endif - - ms_oservices->addItem(GenericMenuSeparator); - // shoutcast shoutcast_onoff = new CMenuOptionChooser(LOCALE_SHOUTCAST_ENABLED, &g_settings.shoutcast_enabled, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, CApiKey::check_shoutcast_dev_id()); shoutcast_onoff->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_SHOUTCAST_ENABLED); @@ -701,6 +686,21 @@ int CMiscMenue::showMiscSettingsMenuOnlineServices() ms_oservices->addItem(mf_sc); #endif + ms_oservices->addItem(GenericMenuSeparator); + + // youtube + youtube_onoff = new CMenuOptionChooser(LOCALE_YOUTUBE_ENABLED, &g_settings.youtube_enabled, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, CApiKey::check_youtube_dev_id()); + youtube_onoff->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_YOUTUBE_ENABLED); + ms_oservices->addItem(youtube_onoff); + +#if ENABLE_YOUTUBE_KEY_MANAGE + changeNotify(LOCALE_YOUTUBE_DEV_ID, NULL); + CKeyboardInput youtube_dev_id_input(LOCALE_YOUTUBE_DEV_ID, &g_settings.youtube_dev_id, 39, this); + CMenuForwarder *mf_yt = new CMenuForwarder(LOCALE_YOUTUBE_DEV_ID, true, youtube_dev_id_short, &youtube_dev_id_input); + mf_yt->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_YOUTUBE_DEV_ID); + ms_oservices->addItem(mf_yt); +#endif + int res = ms_oservices->exec(NULL, ""); delete ms_oservices; return res; @@ -869,15 +869,6 @@ bool CMiscMenue::changeNotify(const neutrino_locale_t OptionName, void */*data*/ omdb_api_key_short.clear(); omdb_onoff->setActive(CApiKey::check_omdb_api_key()); } - else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_YOUTUBE_DEV_ID)) - { - g_settings.youtube_enabled = g_settings.youtube_enabled && CApiKey::check_youtube_dev_id(); - if (g_settings.youtube_enabled) - youtube_dev_id_short = g_settings.youtube_dev_id.substr(0, 8) + "..."; - else - youtube_dev_id_short.clear(); - youtube_onoff->setActive(CApiKey::check_youtube_dev_id()); - } else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_SHOUTCAST_DEV_ID)) { g_settings.shoutcast_enabled = g_settings.shoutcast_enabled && CApiKey::check_shoutcast_dev_id(); @@ -887,6 +878,15 @@ bool CMiscMenue::changeNotify(const neutrino_locale_t OptionName, void */*data*/ shoutcast_dev_id_short.clear(); shoutcast_onoff->setActive(CApiKey::check_shoutcast_dev_id()); } + else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_YOUTUBE_DEV_ID)) + { + g_settings.youtube_enabled = g_settings.youtube_enabled && CApiKey::check_youtube_dev_id(); + if (g_settings.youtube_enabled) + youtube_dev_id_short = g_settings.youtube_dev_id.substr(0, 8) + "..."; + else + youtube_dev_id_short.clear(); + youtube_onoff->setActive(CApiKey::check_youtube_dev_id()); + } else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_STREAMING_PORT)) { CStreamManager::getInstance()->SetPort(g_settings.streaming_port); diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index fb6044999..497adf151 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -72,7 +72,6 @@ #include #include //#include -#include #include #include #include @@ -505,15 +504,6 @@ void CMovieBrowser::initGlobalSettings(void) m_settings.browserAdditional = 0; m_settings.ts_only = 1; - m_settings.ytmode = cYTFeedParser::MOST_POPULAR; - m_settings.ytorderby = cYTFeedParser::ORDERBY_PUBLISHED; - m_settings.ytresults = 10; - m_settings.ytregion = "default"; - m_settings.ytquality = 37; - m_settings.ytconcconn = 4; - m_settings.ytsearch_history_max = 0; - m_settings.ytsearch_history_size = 0; - m_settings.ytthumbnaildir = "/tmp/ytparser"; } void CMovieBrowser::initFrames(void) @@ -690,26 +680,6 @@ bool CMovieBrowser::loadSettings(MB_SETTINGS* settings) } settings->browserAdditional = configfile.getInt32("mb_browserAdditional", 0); - 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 - settings->ytregion = configfile.getString("mb_ytregion", "default"); - settings->ytsearch = configfile.getString("mb_ytsearch", ""); - settings->ytthumbnaildir = configfile.getString("mb_ytthumbnaildir", "/tmp/ytparser"); - settings->ytvid = configfile.getString("mb_ytvid", ""); - settings->ytsearch_history_max = configfile.getInt32("mb_ytsearch_history_max", 10); - settings->ytsearch_history_size = configfile.getInt32("mb_ytsearch_history_size", 0); - if (settings->ytsearch_history_size > settings->ytsearch_history_max) - settings->ytsearch_history_size = settings->ytsearch_history_max; - settings->ytsearch_history.clear(); - for (int i = 0; i < settings->ytsearch_history_size; i++) { - std::string s = configfile.getString("mb_ytsearch_history_" + to_string(i)); - if (!s.empty()) - settings->ytsearch_history.push_back(configfile.getString("mb_ytsearch_history_" + to_string(i), "")); - } - settings->ytsearch_history_size = settings->ytsearch_history.size(); return (result); } @@ -761,27 +731,9 @@ bool CMovieBrowser::saveSettings(MB_SETTINGS* settings) } configfile.setInt32("mb_browserAdditional", settings->browserAdditional); - 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); - configfile.setString("mb_ytregion", settings->ytregion); - configfile.setString("mb_ytsearch", settings->ytsearch); - configfile.setString("mb_ytthumbnaildir", settings->ytthumbnaildir); - configfile.setString("mb_ytvid", settings->ytvid); - - settings->ytsearch_history_size = settings->ytsearch_history.size(); - if (settings->ytsearch_history_size > settings->ytsearch_history_max) - settings->ytsearch_history_size = settings->ytsearch_history_max; - configfile.setInt32("mb_ytsearch_history_max", settings->ytsearch_history_max); - configfile.setInt32("mb_ytsearch_history_size", settings->ytsearch_history_size); - std::list:: iterator it = settings->ytsearch_history.begin(); - for (int i = 0; i < settings->ytsearch_history_size; i++, ++it) - configfile.setString("mb_ytsearch_history_" + to_string(i), *it); - if (configfile.getModifiedFlag()) configfile.saveConfig(MOVIEBROWSER_SETTINGS_FILE); + return (result); } @@ -970,11 +922,6 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) showMenu(true); saveSettings(&m_settings); } - else if(actionKey == "show_ytmenu") - { - showYTMenu(true); - saveSettings(&m_settings); - } else if (actionKey == "copy_onefile" || actionKey == "copy_several") { bool onefile = (actionKey == "copy_onefile"); @@ -1187,9 +1134,6 @@ int CMovieBrowser::exec(const char* path) m_currentStartPos = showStartPosSelectionMenu(); // display start menu m_currentStartPos = } - if (show_mode == MB_SHOW_YT) - cYTCache::getInstance()->useCachedCopy(m_movieSelectionHandler); - if (m_currentStartPos >= 0) { playing_info = m_movieSelectionHandler; TRACE("[mb] start pos: %d s\n",m_currentStartPos); @@ -1199,19 +1143,6 @@ int CMovieBrowser::exec(const char* path) refresh(); } } - else if ((show_mode == MB_SHOW_YT) && (msg == (neutrino_msg_t) g_settings.key_record) && m_movieSelectionHandler) - { - m_movieSelectionHandler->source = (show_mode == MB_SHOW_YT) ? MI_MOVIE_INFO::YT : MI_MOVIE_INFO::NK; - 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 (CNeutrinoApp::getInstance()->backKey(msg)) { loop = false; @@ -1384,10 +1315,7 @@ int CMovieBrowser::paint(void) refreshLCD(); if (m_settings.gui == MB_GUI_FILTER) m_settings.gui = MB_GUI_MOVIE_INFO; - if (show_mode == MB_SHOW_YT) - onSetGUIWindow(MB_GUI_MOVIE_INFO); - else - onSetGUIWindow(m_settings.gui); + onSetGUIWindow(m_settings.gui); return (true); } @@ -1516,20 +1444,12 @@ void CMovieBrowser::initMovieCover(void) cover_h = movieCoverBox.iHeight - 2*OFFSET_INNER_MID - OFFSET_SHADOW; } - std::string cover_file; - if (show_mode == MB_SHOW_YT) + std::string cover_file = getScreenshotName(m_movieSelectionHandler->file.Name, S_ISDIR(m_movieSelectionHandler->file.Mode)); + if ((cover_file.empty()) && (m_movieSelectionHandler->file.Name.length() > 18)) { - cover_file = m_movieSelectionHandler->tfile; - } - else - { - cover_file = getScreenshotName(m_movieSelectionHandler->file.Name, S_ISDIR(m_movieSelectionHandler->file.Mode)); - if ((cover_file.empty()) && (m_movieSelectionHandler->file.Name.length() > 18)) - { - std::string cover = m_movieSelectionHandler->file.Name; - cover.replace((cover.length()-18), 15, ""); //covername without yyyymmdd_hhmmss - cover_file = getScreenshotName(cover); - } + std::string cover = m_movieSelectionHandler->file.Name; + cover.replace((cover.length()-18), 15, ""); //covername without yyyymmdd_hhmmss + cover_file = getScreenshotName(cover); } bool got_cover = !cover_file.empty(); @@ -2038,15 +1958,6 @@ void CMovieBrowser::refreshTitle(void) { std::string title = m_textTitle.c_str(); const char *icon = NEUTRINO_ICON_MOVIEPLAYER; - if (show_mode == MB_SHOW_YT) { - title = g_Locale->getText(LOCALE_MOVIEPLAYER_YTPLAYBACK); - title += " : "; - neutrino_locale_t loc = getFeedLocale(); - title += g_Locale->getText(loc); - if (loc == LOCALE_MOVIEBROWSER_YT_RELATED || loc == LOCALE_MOVIEBROWSER_YT_SEARCH) - title += " \"" + m_settings.ytsearch + "\""; - icon = NEUTRINO_ICON_YTPLAY; - } TRACE("[mb]->refreshTitle: %s\n", title.c_str()); @@ -2206,14 +2117,14 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) { if (m_settings.browserAdditional && m_windowFocus == MB_FOCUS_BROWSER) onSetFocusNext(); - else if (show_mode != MB_SHOW_YT) + else onSetGUIWindowNext(); } else if (msg == (neutrino_msg_t) g_settings.mbkey_toggle_view_ccw) { if (m_settings.browserAdditional && m_windowFocus == MB_FOCUS_MOVIE_INFO2) onSetFocusNext(); - else if (show_mode != MB_SHOW_YT) + else onSetGUIWindowPrev(); } else if (CNeutrinoApp::getInstance()->backKey(msg)) @@ -2237,9 +2148,6 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) } else if (msg == CRCInput::RC_blue) { - if (show_mode == MB_SHOW_YT) - ytparser.Cleanup(); - loadMovies(); refresh(); } @@ -2319,16 +2227,12 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) } else if (msg == CRCInput::RC_setup) { - if (show_mode == MB_SHOW_YT) - showYTMenu(); - else - { - showMenu(); - if (m_doLoadMovies) - loadMovies(); - if (m_doRefresh) - refresh(); - } + showMenu(); + if (m_doLoadMovies) + loadMovies(); + if (m_doRefresh) + refresh(); + saveSettings(&m_settings); } else if (g_settings.sms_movie && (msg >= CRCInput::RC_1) && (msg <= CRCInput::RC_9)) @@ -2413,24 +2317,6 @@ void CMovieBrowser::markItem(CListFrame *list) void CMovieBrowser::scrollBrowserItem(bool next, bool page) { - int mode = -1; - if (show_mode == MB_SHOW_YT && next && ytparser.HaveNext() && m_pcBrowser->getSelectedLine() == m_pcBrowser->getLines() - 1) - mode = cYTFeedParser::NEXT; - if (show_mode == MB_SHOW_YT && !next && ytparser.HavePrev() && m_pcBrowser->getSelectedLine() == 0) - mode = cYTFeedParser::PREV; - if (mode >= 0) { - CHintBox loadBox(LOCALE_MOVIEPLAYER_YTPLAYBACK, (show_mode == MB_SHOW_YT) - ? g_Locale->getText(LOCALE_MOVIEBROWSER_SCAN_FOR_VIDEOS) - : g_Locale->getText(LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES), 450); - loadBox.paint(); - ytparser.Cleanup(); - loadYTitles(mode, m_settings.ytsearch, m_settings.ytvid); - loadBox.hide(); - refreshBrowserList(); - refreshMovieInfo(); - g_RCInput->clearRCMsg(); - return; - } if (next) page ? m_pcBrowser->scrollPageDown(1) : m_pcBrowser->scrollLineDown(1); else @@ -3374,23 +3260,16 @@ void CMovieBrowser::loadMovies(bool doRefresh) struct timeval t1, t2; gettimeofday(&t1, NULL); - CProgressWindowA loadBox((show_mode == MB_SHOW_YT) ? LOCALE_MOVIEPLAYER_YTPLAYBACK : LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES, - CCW_PERCENT 50, - CCW_PERCENT 10, - show_mode == MB_SHOW_YT ? &ytparser.OnProgress : &OnProgress, - show_mode == MB_SHOW_YT ? NULL : &OnSetGlobalMax); + CProgressWindowA loadBox(LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES, CCW_PERCENT 50, CCW_PERCENT 10, &OnProgress, &OnSetGlobalMax); loadBox.enableShadow(); loadBox.paint(); - if (show_mode == MB_SHOW_YT) { - loadYTitles(m_settings.ytmode, m_settings.ytsearch, m_settings.ytvid); - } else { - loadAllTsFileNamesFromStorage(); // P1 - m_seriename_stale = true; // we reloded the movie info, so make sure the other list are updated later on as well - updateSerienames(); - if (m_settings.serie_auto_create == 1) - autoFindSerie(); - } + loadAllTsFileNamesFromStorage(); // P1 + m_seriename_stale = true; // we reloded the movie info, so make sure the other list are updated later on as well + updateSerienames(); + if (m_settings.serie_auto_create == 1) + autoFindSerie(); + m_file_info_stale = false; gettimeofday(&t2, NULL); @@ -4060,13 +3939,9 @@ bool CMovieBrowser::getMovieInfoItem(MI_MOVIE_INFO& movie_info, MB_INFO_ITEM ite } break; case MB_INFO_RECORDDATE: // = 13, - if (show_mode == MB_SHOW_YT) { - *item_string = movie_info.ytdate; - } else { - tm_tmp = localtime(&movie_info.file.Time); - snprintf(str_tmp, sizeof(str_tmp),"%02d.%02d.%02d",tm_tmp->tm_mday,(tm_tmp->tm_mon) + 1,tm_tmp->tm_year >= 100 ? tm_tmp->tm_year-100 : tm_tmp->tm_year); - *item_string = str_tmp; - } + tm_tmp = localtime(&movie_info.file.Time); + snprintf(str_tmp, sizeof(str_tmp),"%02d.%02d.%02d",tm_tmp->tm_mday,(tm_tmp->tm_mon) + 1,tm_tmp->tm_year >= 100 ? tm_tmp->tm_year-100 : tm_tmp->tm_year); + *item_string = str_tmp; break; case MB_INFO_PRODDATE: // = 14, snprintf(str_tmp, sizeof(str_tmp),"%d",movie_info.productionDate); @@ -4183,413 +4058,6 @@ void CMovieBrowser::autoFindSerie(void) } } -void CMovieBrowser::loadYTitles(int mode, std::string search, std::string id) -{ - printf("CMovieBrowser::loadYTitles: parsed %d old mode %d new mode %d region %s\n", ytparser.Parsed(), ytparser.GetFeedMode(), m_settings.ytmode, m_settings.ytregion.c_str()); - if (m_settings.ytregion == "default") - ytparser.SetRegion(""); - else - ytparser.SetRegion(m_settings.ytregion); - - ytparser.SetMaxResults(m_settings.ytresults); - ytparser.SetConcurrentDownloads(m_settings.ytconcconn); - ytparser.SetThumbnailDir(m_settings.ytthumbnaildir); - - if (!ytparser.Parsed() || (ytparser.GetFeedMode() != mode)) { - 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 - DisplayErrorMessage(g_Locale->getText(LOCALE_MOVIEBROWSER_YT_ERROR)); - return; - } - } - m_vMovieInfo.clear(); - yt_video_list_t &ylist = ytparser.GetVideoList(); - for (unsigned i = 0; i < ylist.size(); i++) { - MI_MOVIE_INFO movieInfo; - movieInfo.channelName = ylist[i].author; - movieInfo.epgTitle = htmlEntityDecode(ylist[i].title); - movieInfo.epgInfo1 = ylist[i].category; - movieInfo.epgInfo2 = ylist[i].description; - movieInfo.length = ylist[i].duration/60 ; - movieInfo.tfile = ylist[i].tfile; - movieInfo.ytdate = ylist[i].published; - movieInfo.ytid = ylist[i].id; - movieInfo.file.Name = ylist[i].title; - movieInfo.ytitag = m_settings.ytquality; - movieInfo.file.Url = ylist[i].GetUrl(&movieInfo.ytitag, false); - movieInfo.file.Time = toEpoch(movieInfo.ytdate); - m_vMovieInfo.push_back(movieInfo); - } - m_currentBrowserSelection = 0; - m_currentRecordSelection = 0; - m_currentPlaySelection = 0; - m_pcBrowser->setSelectedLine(m_currentBrowserSelection); - m_pcLastRecord->setSelectedLine(m_currentRecordSelection); - m_pcLastPlay->setSelectedLine(m_currentPlaySelection); -} - -const CMenuOptionChooser::keyval YT_FEED_OPTIONS[] = -{ - { cYTFeedParser::MOST_POPULAR_ALL_TIME, LOCALE_MOVIEBROWSER_YT_MOST_POPULAR_ALL_TIME }, - { cYTFeedParser::MOST_POPULAR, LOCALE_MOVIEBROWSER_YT_MOST_POPULAR } -}; - -#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; - - if (m_settings.ytmode == cYTFeedParser::RELATED) - return LOCALE_MOVIEBROWSER_YT_RELATED; - - if (m_settings.ytmode == cYTFeedParser::SEARCH) - return LOCALE_MOVIEBROWSER_YT_SEARCH; - - for (unsigned i = 0; i < YT_FEED_OPTION_COUNT; i++) { - if (m_settings.ytmode == YT_FEED_OPTIONS[i].key) - return YT_FEED_OPTIONS[i].value; - } - return ret; -} - -int CYTCacheSelectorTarget::exec(CMenuTarget* /*parent*/, const std::string & actionKey) -{ - MI_MOVIE_INFO::miSource source = (movieBrowser->show_mode == MB_SHOW_YT) ? MI_MOVIE_INFO::YT : MI_MOVIE_INFO::NK; - - int selected = movieBrowser->yt_menue->getSelected(); - if (actionKey == "cancel_all") { - cYTCache::getInstance()->cancelAll(source); - } else if (actionKey == "completed_clear") { - cYTCache::getInstance()->clearCompleted(source); - } else if (actionKey == "failed_clear") { - cYTCache::getInstance()->clearFailed(source); - } else if (actionKey == "rc_spkr" && movieBrowser->yt_pending_offset && selected >= movieBrowser->yt_pending_offset && selected < movieBrowser->yt_pending_end) { - cYTCache::getInstance()->cancel(&movieBrowser->yt_pending[selected - movieBrowser->yt_pending_offset]); - } else if (actionKey == "rc_spkr" && movieBrowser->yt_completed_offset && selected >= movieBrowser->yt_completed_offset && selected < movieBrowser->yt_completed_end) { - cYTCache::getInstance()->remove(&movieBrowser->yt_completed[selected - movieBrowser->yt_completed_offset]); - } else if (actionKey.empty()) { - if (movieBrowser->yt_pending_offset && selected >= movieBrowser->yt_pending_offset && selected < movieBrowser->yt_pending_end) { - if (ShowMsg (LOCALE_MOVIEBROWSER_YT_CACHE, g_Locale->getText(LOCALE_MOVIEBROWSER_YT_CANCEL_TRANSFER), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo) == CMsgBox::mbrYes) - cYTCache::getInstance()->cancel(&movieBrowser->yt_pending[selected - movieBrowser->yt_pending_offset]); - else - return menu_return::RETURN_NONE; - } else if (movieBrowser->yt_completed_offset && selected >= movieBrowser->yt_completed_offset && selected < movieBrowser->yt_completed_end) { - // FIXME -- anything sensible to do here? - return menu_return::RETURN_NONE; - } else if (movieBrowser->yt_failed_offset && selected >= movieBrowser->yt_failed_offset && selected < movieBrowser->yt_failed_end){ - 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--) { - yt_menue->removeItem(item_id); - } - MI_MOVIE_INFO::miSource source = (show_mode == MB_SHOW_YT) ? MI_MOVIE_INFO::YT : MI_MOVIE_INFO::NK; - double dltotal, dlnow; - time_t dlstart; - yt_pending = cYTCache::getInstance()->getPending(source, &dltotal, &dlnow, &dlstart); - yt_completed = cYTCache::getInstance()->getCompleted(source); - yt_failed = cYTCache::getInstance()->getFailed(source); - - yt_pending_offset = 0; - yt_completed_offset = 0; - yt_failed_offset = 0; - yt_pending_end = 0; - yt_completed_end = 0; - yt_failed_end = 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); - std::string progress; - if (dlstart && (int64_t)dltotal && (int64_t)dlnow) { - time_t done = time(NULL) - dlstart; - time_t left = ((dltotal - dlnow) * done)/dlnow; - progress = "(" + to_string(done) + "s/" + to_string(left) + "s)"; - } - int i = 0; - yt_pending_offset = yt_menue->getItemsCount(); - for (std::vector::iterator it = yt_pending.begin(); it != yt_pending.end(); ++it, ++i) { - yt_menue->addItem(new CMenuForwarder((*it).file.Name, true, progress.c_str(), ytcache_selector)); - progress = ""; - } - yt_pending_end = yt_menue->getItemsCount(); - } - - 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::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)); - } - yt_completed_end = yt_menue->getItemsCount(); - } - - 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::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)); - } - yt_failed_end = yt_menue->getItemsCount(); - } - - CFrameBuffer::getInstance()->Clear(); // due to possible width change -} - -class CYTHistory : public CMenuTarget -{ - private: - int width; - int selected; - bool allexit; - std::string *search; - MB_SETTINGS *settings; - public: - CYTHistory(MB_SETTINGS &_settings, std::string &_search); - int exec(CMenuTarget* parent, const std::string & actionKey); -}; - -CYTHistory::CYTHistory(MB_SETTINGS &_settings, std::string &_search) -{ - width = 40; - selected = -1; - settings = &_settings; - search = &_search; - allexit = false; -} - -int CYTHistory::exec(CMenuTarget* parent, const std::string &actionKey) -{ - if (actionKey.empty()) { - if (parent) - parent->hide(); - CMenuWidget* m = new CMenuWidget(LOCALE_MOVIEBROWSER_YT_HISTORY, NEUTRINO_ICON_MOVIEPLAYER, width); - m->addKey(CRCInput::RC_spkr, this, "clearYThistory"); - m->setSelected(selected); - m->addItem(GenericMenuSeparator); - m->addItem(GenericMenuBack); - m->addItem(GenericMenuSeparatorLine); - std::list::iterator it = settings->ytsearch_history.begin(); - for (int i = 0; i < settings->ytsearch_history_size; i++, ++it) - m->addItem(new CMenuForwarder((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1))); - m->exec(NULL, ""); - m->hide(); - delete m; - if(!allexit) { - return menu_return::RETURN_REPAINT; - }else { - allexit = false; - return menu_return::RETURN_EXIT_ALL; - } - } - if (actionKey == "clearYThistory") { - settings->ytsearch_history.clear(); - settings->ytsearch_history_size = 0; - return menu_return::RETURN_EXIT; - } - *search = actionKey; - allexit = true; - return menu_return::RETURN_EXIT; -} - -bool CMovieBrowser::showYTMenu(bool calledExternally) -{ - framebuffer->paintBackground(); - - CMenuWidget mainMenu(LOCALE_MOVIEPLAYER_YTPLAYBACK, NEUTRINO_ICON_MOVIEPLAYER); - mainMenu.addIntroItems(LOCALE_MOVIEBROWSER_MENU_SETTINGS); - - int select = -1; - CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - - char cnt[5]; - if (!calledExternally) { - for (unsigned i = 0; i < YT_FEED_OPTION_COUNT; i++) { - sprintf(cnt, "%d", YT_FEED_OPTIONS[i].key); - mainMenu.addItem(new CMenuForwarder(YT_FEED_OPTIONS[i].value, true, NULL, selector, cnt, CRCInput::convertDigitToKey(i + 1)), m_settings.ytmode == (int) YT_FEED_OPTIONS[i].key); - } - mainMenu.addItem(GenericMenuSeparatorLine); - - bool enabled = (!m_vMovieInfo.empty()) && (m_movieSelectionHandler != NULL); - sprintf(cnt, "%d", cYTFeedParser::RELATED); - mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_RELATED, enabled, NULL, selector, cnt, CRCInput::RC_red)); - - mainMenu.addItem(GenericMenuSeparatorLine); - } - - std::string search = m_settings.ytsearch; - CKeyboardInput stringInput(LOCALE_MOVIEBROWSER_YT_SEARCH, &search); - if (!calledExternally) { - mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_SEARCH, true, search, &stringInput, NULL, CRCInput::RC_green)); - 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_yellow)); - } - - CYTHistory ytHistory(m_settings, search); - if (!calledExternally) { - if (m_settings.ytsearch_history_size > 0) - mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_HISTORY, true, NULL, &ytHistory, "", CRCInput::RC_blue)); - - mainMenu.addItem(GenericMenuSeparatorLine); - } - mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_MAX_RESULTS, &m_settings.ytresults, true, 10, 50, NULL)); - mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_MAX_HISTORY, &m_settings.ytsearch_history_max, true, 10, 50, NULL)); - - std::string rstr = m_settings.ytregion; - CMenuOptionStringChooser * region = new CMenuOptionStringChooser(LOCALE_MOVIEBROWSER_YT_REGION, &rstr, true, NULL, CRCInput::RC_nokey, "", true); - region->addOption("default"); - region->addOption("DE"); - region->addOption("PL"); - region->addOption("RU"); - region->addOption("NL"); - region->addOption("CZ"); - region->addOption("FR"); - region->addOption("HU"); - region->addOption("US"); - 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.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_CONCURRENT_CONNECTIONS, &m_settings.ytconcconn, true, 1, 8)); - - CFileChooser fc(&m_settings.ytthumbnaildir); - mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_CACHE_DIR, true, m_settings.ytthumbnaildir, &fc)); - CFileChooser fcdl(&g_settings.downloadcache_dir); - mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_DL_DIR, true, g_settings.downloadcache_dir, &fcdl)); - - 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(); - - int ret = mainMenu.exec(NULL, ""); - - ytparser.SetConcurrentDownloads(m_settings.ytconcconn); - ytparser.SetThumbnailDir(m_settings.ytthumbnaildir); - - delete selector; - - bool reload = false; - int newmode = -1; - if (rstr != m_settings.ytregion) { - m_settings.ytregion = rstr; - if (newmode < 0) - newmode = m_settings.ytmode; - reload = true; - printf("change region to %s\n", m_settings.ytregion.c_str()); - } - if (calledExternally) - return true; - - if (ret == menu_return::RETURN_EXIT_ALL && !search.empty() && !m_settings.ytsearch.empty() && search != m_settings.ytsearch){ - select = cYTFeedParser::SEARCH; - } - - printf("MovieBrowser::showYTMenu(): selected: %d\n", select); - if (select >= 0) { - newmode = select; - if (select == cYTFeedParser::RELATED) { - if (m_settings.ytvid != m_movieSelectionHandler->ytid) { - printf("get related for: %s\n", m_movieSelectionHandler->ytid.c_str()); - m_settings.ytvid = m_movieSelectionHandler->ytid; - m_settings.ytmode = newmode; - reload = true; - } - } - else if (select == cYTFeedParser::SEARCH) { - printf("search for: %s\n", search.c_str()); - if (!search.empty()) { - reload = true; - m_settings.ytsearch = search; - m_settings.ytmode = newmode; - m_settings.ytsearch_history.push_front(search); - std::list::iterator it = m_settings.ytsearch_history.begin(); - ++it; - while (it != m_settings.ytsearch_history.end()) { - if (*it == search) - it = m_settings.ytsearch_history.erase(it); - else - ++it; - } - if (m_settings.ytsearch_history.empty()) - m_settings.ytsearch_history_size = 0; - else - m_settings.ytsearch_history_size = m_settings.ytsearch_history.size(); - - if (m_settings.ytsearch_history_size > m_settings.ytsearch_history_max) - m_settings.ytsearch_history_size = m_settings.ytsearch_history_max; - } - } - else if (m_settings.ytmode != newmode) { - m_settings.ytmode = newmode; - reload = true; - } - } - - if (reload) { - CHintBox loadBox(LOCALE_MOVIEPLAYER_YTPLAYBACK, LOCALE_MOVIEBROWSER_SCAN_FOR_VIDEOS, 450); - loadBox.paint(); - ytparser.Cleanup(); - loadYTitles(newmode, m_settings.ytsearch, m_settings.ytvid); - loadBox.hide(); - } - refreshBrowserList(); - refreshLastPlayList(); - refreshLastRecordList(); - refreshFilterList(); - refresh(); - return true; -} - CMenuSelector::CMenuSelector(const char * OptionName, const bool Active, char * OptionValue, int* ReturnInt,int ReturnIntValue) : CMenuItem() { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); diff --git a/src/gui/moviebrowser/mb.h b/src/gui/moviebrowser/mb.h index 9ab4a975a..449ba1914 100644 --- a/src/gui/moviebrowser/mb.h +++ b/src/gui/moviebrowser/mb.h @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -119,38 +118,13 @@ typedef struct int lastRecordRowNr; MB_INFO_ITEM lastRecordRow[3]; int lastRecordRowWidth[3]; - - int ytmode; - int ytorderby; - int ytresults; - int ytquality; - int ytconcconn; - int ytsearch_history_size; - int ytsearch_history_max; - std::string ytregion; - std::string ytvid; - std::string ytsearch; - std::string ytthumbnaildir; - std::list 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, public CProgressSignals { - 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 @@ -246,23 +220,7 @@ class CMovieBrowser : public CMenuTarget, public CProgressSignals int menu_ret; - 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; - int yt_pending_end; - int yt_completed_end; - int yt_failed_end; - std::vector yt_pending; - std::vector yt_completed; - std::vector yt_failed; - void loadYTitles(int mode, std::string search = "", std::string id = ""); - bool showYTMenu(bool calledExternally = false); - void refreshYTMenu(); public: // Functions //////////////////////////////////////////////////////////7 CMovieBrowser(); //P1 diff --git a/src/gui/moviebrowser/mb_types.h b/src/gui/moviebrowser/mb_types.h index 98d4c446f..edb250aae 100644 --- a/src/gui/moviebrowser/mb_types.h +++ b/src/gui/moviebrowser/mb_types.h @@ -139,8 +139,7 @@ typedef struct typedef enum { MB_SHOW_RECORDS, - MB_SHOW_FILES, - MB_SHOW_YT + MB_SHOW_FILES } MB_SHOW_MODE; typedef enum diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 19076adc0..e4b0d638b 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -430,13 +430,6 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) moviebrowser->setMode(MB_SHOW_RECORDS); //wakeup_hdd(g_settings.network_nfs_recordingdir.c_str()); } -#if ENABLE_YOUTUBE_PLAYER - else if (actionKey == "ytplayback") { - isMovieBrowser = true; - moviebrowser->setMode(MB_SHOW_YT); - isYT = true; - } -#endif else if (actionKey == "fileplayback_video") { is_audio_playing = false; if (filebrowser) @@ -727,7 +720,6 @@ void CMoviePlayerGui::ClearFlags() isLuaPlay = false; isUPNP = false; isWebChannel = false; - isYT = false; is_file_player = false; is_audio_playing = false; timeshift = TSHIFT_MODE_OFF; @@ -803,10 +795,6 @@ bool CMoviePlayerGui::prepareFile(CFile *file) printf("CMoviePlayerGui::prepareFile: file %s start %d\n", file_name.c_str(), startposition); } } - if (isYT) { - file_name = file->Url; - is_file_player = true; - } fillPids(); } if (file->getType() == CFile::FILE_ISO) @@ -1920,7 +1908,7 @@ void CMoviePlayerGui::PlayFileLoop(void) filelist_it = vzap_it; } fromInfoviewer = false; - } else if (timeshift == TSHIFT_MODE_OFF && !isWebChannel /* && !isYT */ && (msg == (neutrino_msg_t) g_settings.mpkey_next_repeat_mode)) { + } else if (timeshift == TSHIFT_MODE_OFF && !isWebChannel && (msg == (neutrino_msg_t) g_settings.mpkey_next_repeat_mode)) { repeat_mode = (repeat_mode_enum)((int)repeat_mode + 1); if (repeat_mode > (int) REPEAT_ALL) repeat_mode = REPEAT_OFF; @@ -2671,7 +2659,7 @@ void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int /*position*/) if (p_movie_info->length == 0) { p_movie_info->length = (float)duration / 60 / 1000 + 0.5; } - if (!isYT && !isHTTP && !isUPNP) + if (!isHTTP && !isUPNP) cMovieInfo.saveMovieInfo(*p_movie_info); //p_movie_info->fileInfoStale(); //TODO: we might to tell the Moviebrowser that the movie info has changed, but this could cause long reload times when reentering the Moviebrowser } @@ -2782,7 +2770,7 @@ void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int /*position*/) new_bookmark.length = play_sec - new_bookmark.pos; TRACE("[mp] commercial length: %d\r\n", new_bookmark.length); if (cMovieInfo.addNewBookmark(p_movie_info, new_bookmark) == true) { - if (!isYT && !isHTTP && !isUPNP) + if (!isHTTP && !isUPNP) cMovieInfo.saveMovieInfo(*p_movie_info); /* save immediately in xml file */ } new_bookmark.pos = 0; // clear again, since this is used as flag for bookmark activity @@ -2793,7 +2781,7 @@ void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int /*position*/) new_bookmark.pos = play_sec; TRACE("[mp] loop length: %d\r\n", new_bookmark.length); if (cMovieInfo.addNewBookmark(p_movie_info, new_bookmark) == true) { - if (!isYT && !isHTTP && !isUPNP) + if (!isHTTP && !isUPNP) cMovieInfo.saveMovieInfo(*p_movie_info); /* save immediately in xml file */ jump_not_until = play_sec + 5; // avoid jumping for this time } @@ -2865,7 +2853,7 @@ void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int /*position*/) new_bookmark.pos = play_sec; new_bookmark.length = 0; if (cMovieInfo.addNewBookmark(p_movie_info, new_bookmark) == true) - if (!isYT && !isHTTP && !isUPNP) + if (!isHTTP && !isUPNP) cMovieInfo.saveMovieInfo(*p_movie_info); /* save immediately in xml file */ new_bookmark.pos = 0; // clear again, since this is used as flag for bookmark activity } else if (cSelectedMenuBookStart[3].selected == true) { @@ -2882,13 +2870,13 @@ void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int /*position*/) /* Moviebrowser movie start bookmark */ p_movie_info->bookmarks.start = play_sec; TRACE("[mp] New movie start pos: %d\r\n", p_movie_info->bookmarks.start); - if (!isYT && !isHTTP && !isUPNP) + if (!isHTTP && !isUPNP) cMovieInfo.saveMovieInfo(*p_movie_info); /* save immediately in xml file */ } else if (cSelectedMenuBookStart[6].selected == true) { /* Moviebrowser movie end bookmark */ p_movie_info->bookmarks.end = play_sec; TRACE("[mp] New movie end pos: %d\r\n", p_movie_info->bookmarks.end); - if (!isYT && !isHTTP && !isUPNP) + if (!isHTTP && !isUPNP) cMovieInfo.saveMovieInfo(*p_movie_info); /* save immediately in xml file */ } } diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index 30d2f314e..50b2e578e 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -170,7 +170,6 @@ class CMoviePlayerGui : public CMenuTarget bool isHTTP; bool isUPNP; bool isWebChannel; - bool isYT; bool showStartingHint; static CMovieBrowser* moviebrowser; MI_MOVIE_INFO movie_info; diff --git a/src/gui/upnpbrowser.h b/src/gui/upnpbrowser.h index fb2047140..fe9914dc1 100644 --- a/src/gui/upnpbrowser.h +++ b/src/gui/upnpbrowser.h @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index ea40bbd17..859dfda84 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -403,15 +403,6 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg) // FIXME menu_item->setHint("", NONEXISTANT_LOCALE); break; } -#if ENABLE_YOUTUBE_PLAYER - case SNeutrinoSettings::ITEM_YOUTUBE: - { - keyhelper.get(&key, &icon); - menu_item = new CMenuForwarder(LOCALE_MOVIEPLAYER_YTPLAYBACK, !_mode_ts, NULL, neutrino, "ytplayback", key, icon); - menu_item->setHint(NEUTRINO_ICON_HINT_YTPLAY, LOCALE_MENU_HINT_YTPLAY); - break; - } -#endif case SNeutrinoSettings::ITEM_FILEPLAY_VIDEO: { keyhelper.get(&key, &icon); diff --git a/src/gui/user_menue_setup.cpp b/src/gui/user_menue_setup.cpp index ed47b782a..6086e8c32 100644 --- a/src/gui/user_menue_setup.cpp +++ b/src/gui/user_menue_setup.cpp @@ -89,7 +89,6 @@ static keyvals usermenu_items[] = { SNeutrinoSettings::ITEM_ECMINFO, LOCALE_ECMINFO_SHOW, usermenu_show }, { SNeutrinoSettings::ITEM_CAMD_RESET, LOCALE_CAMD_RESET, usermenu_show }, { SNeutrinoSettings::ITEM_INFOICONS, LOCALE_INFOICONS_SWITCH_ON, usermenu_show }, - { SNeutrinoSettings::ITEM_YOUTUBE, LOCALE_MOVIEPLAYER_YTPLAYBACK, usermenu_show }, { SNeutrinoSettings::ITEM_FILEPLAY_VIDEO, LOCALE_MOVIEPLAYER_FILEPLAYBACK_VIDEO, usermenu_show }, { SNeutrinoSettings::ITEM_FILEPLAY_AUDIO, LOCALE_MOVIEPLAYER_FILEPLAYBACK_AUDIO, usermenu_show }, { SNeutrinoSettings::ITEM_AUDIOPLAYER, LOCALE_AUDIOPLAYER_NAME, usermenu_show }, diff --git a/src/gui/widget/icons.h b/src/gui/widget/icons.h index 6010a1398..ae03aa3c7 100644 --- a/src/gui/widget/icons.h +++ b/src/gui/widget/icons.h @@ -116,7 +116,6 @@ #define NEUTRINO_ICON_UPDATE "softupdate" #define NEUTRINO_ICON_UPNP "upnp" #define NEUTRINO_ICON_VIDEO "video" -#define NEUTRINO_ICON_YTPLAY "ytplay" /* volumebar */ #define NEUTRINO_ICON_VOLUME "volume" @@ -164,7 +163,6 @@ #define NEUTRINO_ICON_HINT_WEBRADIO "hint_webradio" #define NEUTRINO_ICON_HINT_WEBTV "hint_webtv" #define NEUTRINO_ICON_HINT_XMLTV "hint_xmltv" -#define NEUTRINO_ICON_HINT_YTPLAY "hint_ytplay" #define NEUTRINO_ICON_HINT_MB "hint_mb" #define NEUTRINO_ICON_HINT_FILEPLAY "hint_fileplay" diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 1f324dbed..d34ecd460 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -126,7 +126,6 @@ #include "gui/themes.h" #include "gui/timerlist.h" #include "gui/components/cc_item_progressbar.h" -#include #include #include @@ -1128,7 +1127,7 @@ int CNeutrinoApp::loadSetup(const char *fname) g_settings.weather_location = configfile.getString("weather_location", WEATHER_DEFAULT_LOCATION); g_settings.weather_postalcode = configfile.getString("weather_postalcode", WEATHER_DEFAULT_POSTALCODE); - g_settings.youtube_dev_id = YT_DEV_KEY; + g_settings.youtube_dev_id = YOUTUBE_DEV_KEY; #if ENABLE_YOUTUBE_KEY_MANAGE g_settings.youtube_dev_id = configfile.getString("youtube_dev_id", g_settings.youtube_dev_id.empty() ? "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" : g_settings.youtube_dev_id); #endif @@ -4721,7 +4720,7 @@ void CNeutrinoApp::ExitRun(int exit_code) { bool do_exiting = true; CRecordManager::getInstance()->StopAutoRecord(); - if(CRecordManager::getInstance()->RecordingStatus() || cYTCache::getInstance()->isActive()) + if(CRecordManager::getInstance()->RecordingStatus()) { do_exiting = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECORDING_QUERY, CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo, NULL, 450, DEFAULT_TIMEOUT, true) == CMsgBox::mbrYes); @@ -5539,7 +5538,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) return menu_return::RETURN_EXIT_ALL; } - else if (actionKey=="ytplayback" || actionKey=="tsmoviebrowser" || actionKey=="fileplayback_video" || actionKey=="fileplayback_audio") + else if (actionKey=="tsmoviebrowser" || actionKey=="fileplayback_video" || actionKey=="fileplayback_audio") { frameBuffer->Clear(); if (mode == NeutrinoModes::NeutrinoModes::mode_radio || mode == NeutrinoModes::NeutrinoModes::mode_webradio) diff --git a/src/system/Makefile.am b/src/system/Makefile.am index 630f7f873..e02aa3ffb 100644 --- a/src/system/Makefile.am +++ b/src/system/Makefile.am @@ -42,8 +42,6 @@ libneutrino_system_a_SOURCES = \ settings.cpp \ stacktrace.cpp \ sysload.cpp \ - ytcache.cpp \ - ytparser.cpp \ setting_helpers.cpp # safe_system.c diff --git a/src/system/hddstat.cpp b/src/system/hddstat.cpp index 979dedf24..a72baf551 100644 --- a/src/system/hddstat.cpp +++ b/src/system/hddstat.cpp @@ -36,7 +36,6 @@ #include #include "hddstat.h" #include -//#include #include #include #include @@ -74,7 +73,7 @@ void *cHddStat::Run(void *arg) long long perc = -1; if (caller->once || (g_settings.hdd_statfs_mode == SNeutrinoSettings::HDD_STATFS_ALWAYS) - || (g_settings.hdd_statfs_mode == SNeutrinoSettings::HDD_STATFS_RECORDING && (CRecordManager::getInstance()->RecordingStatus() /* || cYTCache::getInstance()->isActive() */ ))) { + || (g_settings.hdd_statfs_mode == SNeutrinoSettings::HDD_STATFS_RECORDING && (CRecordManager::getInstance()->RecordingStatus()))) { caller->once = false; struct statfs st; if (statfs(_dir.c_str(), &st) || !st.f_blocks) diff --git a/src/system/locals.h b/src/system/locals.h index 0b7888059..b3198b7e7 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1976,8 +1976,6 @@ typedef enum LOCALE_MENU_HINT_XMLTV_SETUP, LOCALE_MENU_HINT_YOUTUBE_DEV_ID, LOCALE_MENU_HINT_YOUTUBE_ENABLED, - LOCALE_MENU_HINT_YTPLAY, - LOCALE_MENU_HINT_YTPLAY_SETUP, LOCALE_MENU_HINT_ZAP_CYCLE, LOCALE_MENU_NEXT, LOCALE_MESSAGE_FRAME_ENABLE, @@ -2273,7 +2271,6 @@ typedef enum LOCALE_MOVIEBROWSER_RELOAD_AT_START, LOCALE_MOVIEBROWSER_REMOUNT_AT_START, LOCALE_MOVIEBROWSER_SCAN_FOR_MOVIES, - LOCALE_MOVIEBROWSER_SCAN_FOR_VIDEOS, LOCALE_MOVIEBROWSER_SERIE_AUTO_CREATE, LOCALE_MOVIEBROWSER_SERIE_HEAD, LOCALE_MOVIEBROWSER_SERIE_NAME, @@ -2312,31 +2309,6 @@ 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_DL_DIR, - LOCALE_MOVIEBROWSER_YT_ERROR, - LOCALE_MOVIEBROWSER_YT_FAILED, - LOCALE_MOVIEBROWSER_YT_HISTORY, - LOCALE_MOVIEBROWSER_YT_MAX_HISTORY, - LOCALE_MOVIEBROWSER_YT_MAX_RESULTS, - LOCALE_MOVIEBROWSER_YT_MOST_POPULAR, - LOCALE_MOVIEBROWSER_YT_MOST_POPULAR_ALL_TIME, - 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_PENDING, - LOCALE_MOVIEBROWSER_YT_PREF_QUALITY, - LOCALE_MOVIEBROWSER_YT_REGION, - LOCALE_MOVIEBROWSER_YT_RELATED, - LOCALE_MOVIEBROWSER_YT_SEARCH, LOCALE_MOVIECUT_CANCEL, LOCALE_MOVIEPLAYER_BISECTION_JUMP, LOCALE_MOVIEPLAYER_BOOKMARK, @@ -2369,7 +2341,6 @@ typedef enum LOCALE_MOVIEPLAYER_TITLES, LOCALE_MOVIEPLAYER_TOOMANYBOOKMARKS, LOCALE_MOVIEPLAYER_TSPLAYBACK, - LOCALE_MOVIEPLAYER_YTPLAYBACK, LOCALE_MOVIEPLAYER_ZAP, LOCALE_MPKEY_AUDIO, LOCALE_MPKEY_BOOKMARK, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index e51fab26c..01d51790e 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1976,8 +1976,6 @@ const char * locale_real_names[] = "menu.hint_xmltv_setup", "menu.hint_youtube_dev_id", "menu.hint_youtube_enabled", - "menu.hint_ytplay", - "menu.hint_ytplay_setup", "menu.hint_zap_cycle", "menu.next", "message.frame_enable", @@ -2273,7 +2271,6 @@ const char * locale_real_names[] = "moviebrowser.reload_at_start", "moviebrowser.remount_at_start", "moviebrowser.scan_for_movies", - "moviebrowser.scan_for_videos", "moviebrowser.serie_auto_create", "moviebrowser.serie_head", "moviebrowser.serie_name", @@ -2312,31 +2309,6 @@ 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_dl_dir", - "moviebrowser.yt_error", - "moviebrowser.yt_failed", - "moviebrowser.yt_history", - "moviebrowser.yt_max_history", - "moviebrowser.yt_max_results", - "moviebrowser.yt_most_popular", - "moviebrowser.yt_most_popular_all_time", - "moviebrowser.yt_orderby", - "moviebrowser.yt_orderby.published", - "moviebrowser.yt_orderby.rating", - "moviebrowser.yt_orderby.relevance", - "moviebrowser.yt_orderby.viewcount", - "moviebrowser.yt_pending", - "moviebrowser.yt_pref_quality", - "moviebrowser.yt_region", - "moviebrowser.yt_related", - "moviebrowser.yt_search", "moviecut.cancel", "movieplayer.bisection_jump", "movieplayer.bookmark", @@ -2369,7 +2341,6 @@ const char * locale_real_names[] = "movieplayer.titles", "movieplayer.toomanybookmarks", "movieplayer.tsplayback", - "movieplayer.ytplayback", "movieplayer.zap", "mpkey.audio", "mpkey.bookmark", diff --git a/src/system/settings.cpp b/src/system/settings.cpp index 11e9d6944..48d9991c4 100644 --- a/src/system/settings.cpp +++ b/src/system/settings.cpp @@ -107,7 +107,6 @@ const struct personalize_settings_t personalize_settings[SNeutrinoSettings::P_SE {"personalize_mplayer_mbrowser" , CPersonalizeGui::PERSONALIZE_MODE_VISIBLE}, {"personalize_mplayer_fileplay_video" , CPersonalizeGui::PERSONALIZE_MODE_VISIBLE}, {"personalize_mplayer_fileplay_audio" , CPersonalizeGui::PERSONALIZE_MODE_VISIBLE}, - {"personalize_mplayer_ytplay" , CPersonalizeGui::PERSONALIZE_MODE_VISIBLE}, //key {"personalize_feat_key_fav" , CPersonalizeGui::PERSONALIZE_FEAT_KEY_GREEN}, diff --git a/src/system/settings.h b/src/system/settings.h index 0cb2d4cea..1432ec88a 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -744,7 +744,6 @@ struct SNeutrinoSettings P_MPLAYER_MBROWSER, P_MPLAYER_FILEPLAY_VIDEO, P_MPLAYER_FILEPLAY_AUDIO, - P_MPLAYER_YTPLAY, // feature keys P_FEAT_KEY_FAVORIT, @@ -1179,7 +1178,6 @@ struct SNeutrinoSettings ITEM_ECMINFO = 22, ITEM_CAMD_RESET = 23, ITEM_INFOICONS = 24, - ITEM_YOUTUBE = 25, ITEM_FILEPLAY_VIDEO = 26, ITEM_TOOLS = 27, ITEM_LUA = 28, diff --git a/src/system/ytcache.cpp b/src/system/ytcache.cpp deleted file mode 100644 index 66b52832d..000000000 --- a/src/system/ytcache.cpp +++ /dev/null @@ -1,415 +0,0 @@ -/* - ytcache.cpp -- cache youtube movies - - Copyright (C) 2013 martii - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "ytcache.h" -#include - -#include -#include -#include -#include -#if LIBCURL_VERSION_NUM < 0x071507 -#include -#endif -#define URL_TIMEOUT 3600 - -#include "helpers.h" -#include "settings.h" -#include "set_threadname.h" -#include -#include - -static cYTCache *instance = NULL; - -cYTCache::cYTCache(void) -{ - cancelled = false; - thread = 0; -} - -cYTCache::~cYTCache(void) -{ - instance = NULL; -} - -cYTCache *cYTCache::getInstance(void) -{ - if (!instance) - instance = new cYTCache(); - return instance; -} - -std::string cYTCache::getName(MI_MOVIE_INFO *mi, std::string ext) -{ - switch (mi->source) { - case MI_MOVIE_INFO::YT: - return g_settings.downloadcache_dir + "/" + mi->ytid + "-" + to_string(mi->ytitag) + "." + ext; - case MI_MOVIE_INFO::NK: - return g_settings.downloadcache_dir + "/nk-" + mi->ytid + "." + ext; - default: - return g_settings.downloadcache_dir + "/error-" + mi->ytid + "." + ext;; - } -} - -bool cYTCache::getNameIfExists(std::string &fname, const std::string &id, int itag, std::string ext) -{ - std::string f = g_settings.downloadcache_dir + "/" + id + "-" + to_string(itag) + "." + ext; - if (access(f, R_OK)) - return false; - fname = f; - return true; -} - -bool cYTCache::useCachedCopy(MI_MOVIE_INFO *mi) -{ - std::string file = getName(mi); - if (access(file, R_OK)) - return false; - std::string xml = getName(mi, "xml"); - if (!access(xml, R_OK)) { - mi->file.Url = file; - return true; - } - { - OpenThreads::ScopedLock m_lock(mutex); - if (pending.empty()) - return false; - MI_MOVIE_INFO m = pending.front(); - if (compareMovieInfo(&m, mi)) { - mi->file.Url = file; - return true; - } - } - - return false; -} - -int cYTCache::curlProgress(void *clientp, double dltotal, double dlnow, double /*ultotal*/, double /*ulnow*/) -{ - cYTCache *caller = (cYTCache *) clientp; - caller->dltotal = dltotal; - caller->dlnow = dlnow; - if (caller->cancelled) - return 1; - return 0; -} - -bool cYTCache::download(MI_MOVIE_INFO *mi) -{ - std::string file = getName(mi); - std::string xml = getName(mi, "xml"); - if (!access(file, R_OK) && !access(xml, R_OK)) { - fprintf(stderr, "%s: %s already present and valid\n", __func__, file.c_str()); - return true; - } - - FILE * fp = fopen(file.c_str(), "wb"); - if (!fp) { - perror(file.c_str()); - return false; - } - - CURL *curl = curl_easy_init(); - if (!curl) { - fclose(fp); - return false; - } - - curl_easy_setopt(curl, CURLOPT_URL, mi->file.Url.c_str()); - curl_easy_setopt(curl, CURLOPT_FILE, fp); - curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(curl, CURLOPT_TIMEOUT, URL_TIMEOUT); - curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, cYTCache::curlProgress); - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this); - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0); - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); - - char cerror[CURL_ERROR_SIZE] = {0}; - curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, cerror); - - if(!g_settings.softupdate_proxyserver.empty()) { - curl_easy_setopt(curl, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str()); - if(!g_settings.softupdate_proxyusername.empty()) { - std::string tmp = g_settings.softupdate_proxyusername + ":" + g_settings.softupdate_proxypassword; - curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, tmp.c_str()); - } - } - - dltotal = 0; - dlnow = 0; - dlstart = time(NULL); - - fprintf (stderr, "downloading %s to %s\n", mi->file.Url.c_str(), file.c_str()); - CURLcode res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - - fclose(fp); - - if (res) { - fprintf (stderr, "downloading %s to %s failed: %s\n", mi->file.Url.c_str(), file.c_str(), cerror); - unlink(file.c_str()); - return false; - } - CMovieInfo cMovieInfo; - CFile File; - File.Name = xml; - cMovieInfo.saveMovieInfo(*mi, &File); - std::string thumbnail_dst = getName(mi, "jpg"); - CFileHelpers fh; - fh.copyFile(mi->tfile.c_str(), thumbnail_dst.c_str(), 0644); - return true; -} - -void *cYTCache::downloadThread(void *arg) { - fprintf(stderr, "%s starting\n", __func__); - set_threadname("ytdownload"); - cYTCache *caller = (cYTCache *)arg; - - //CVFD::getInstance()->ShowIcon(FP_ICON_DOWNLOAD, true); - - while (caller->thread) { - MI_MOVIE_INFO mi; - { - OpenThreads::ScopedLock m_lock(caller->mutex); - if (caller->pending.empty()) { - caller->cancelled = false; - caller->thread = 0; - continue; - } - mi = caller->pending.front(); - } - - - bool res = caller->download(&mi); - - caller->cancelled = false; - - { - OpenThreads::ScopedLock m_lock(caller->mutex); - if (res) - caller->completed.insert(caller->completed.begin(), mi); - else - caller->failed.insert(caller->failed.begin(), mi); - if (caller->pending.empty()) - caller->thread = 0; - else - caller->pending.erase(caller->pending.begin()); - } - } - - //CVFD::getInstance()->ShowIcon(FP_ICON_DOWNLOAD, false); - - fprintf(stderr, "%s exiting\n", __func__); - pthread_exit(NULL); -} - -bool cYTCache::addToCache(MI_MOVIE_INFO *mi) -{ - { - OpenThreads::ScopedLock m_lock(mutex); - pending.push_back(*mi); - } - - if (!thread) { - if (pthread_create(&thread, NULL, downloadThread, this)) { - perror("pthread_create"); - return false; - } - pthread_detach(thread); - } - return true; -} - -void cYTCache::cancel(MI_MOVIE_INFO *mi) -{ - mutex.lock(); - if (pending.empty()) - return; - - if (compareMovieInfo(mi, &pending.front())) { - cancelled = true; - mutex.unlock(); - while (cancelled) - usleep(100000); - return; - } else { - for (std::vector::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 m_lock(mutex); - if (completed.empty()) - return; - - for (std::vector::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(MI_MOVIE_INFO::miSource source) -{ - { - OpenThreads::ScopedLock m_lock(mutex); - if (pending.empty()) - return; - if (pending.size() > 1) - for (std::vector::iterator it = pending.begin() + 1; it != pending.end();){ - if ((*it).source == source) { - failed.push_back(*it); - it = pending.erase(it); - } else - ++it; - } - if (pending.front().source != source) - return; - } - - cancelled = true; - while (thread) - usleep(100000); - - { - OpenThreads::ScopedLock m_lock(mutex); - cancelled = false; - if (!pending.empty()) { - if (pthread_create(&thread, NULL, downloadThread, this)) { - perror("pthread_create"); - return; - } - pthread_detach(thread); - } - } -} - -std::vector cYTCache::getFailed(MI_MOVIE_INFO::miSource source) -{ - OpenThreads::ScopedLock m_lock(mutex); - std::vector res; - for (std::vector::iterator it = failed.begin(); it != failed.end(); ++it) - if ((*it).source == source) - res.push_back(*it); - return res; -} - -std::vector cYTCache::getCompleted(MI_MOVIE_INFO::miSource source) -{ - OpenThreads::ScopedLock m_lock(mutex); - std::vector res; - for (std::vector::iterator it = completed.begin(); it != completed.end(); ++it) - if ((*it).source == source) - res.push_back(*it); - return res; -} - -std::vector cYTCache::getPending(MI_MOVIE_INFO::miSource source, double *p_dltotal, double *p_dlnow, time_t *p_start) -{ - OpenThreads::ScopedLock m_lock(mutex); - std::vector res; - for (std::vector::iterator it = pending.begin(); it != pending.end(); ++it) - if ((*it).source == source) - res.push_back(*it); - if (!res.empty() && pending.front().source == source) { - if (p_dltotal) - *p_dltotal = dltotal; - if (p_dlnow) - *p_dlnow = dlnow; - if (p_start) - *p_start = dlstart; - } else { - if (p_dltotal) - *p_dltotal = 0; - if (p_dlnow) - *p_dlnow = 0; - if (p_start) - *p_start = 0; - } - return res; -} - -void cYTCache::clearFailed(MI_MOVIE_INFO *mi) -{ - OpenThreads::ScopedLock m_lock(mutex); - if (mi) { - for (std::vector::iterator it = failed.begin(); it != failed.end(); ++it) - if (compareMovieInfo(&(*it), mi)) { - failed.erase(it); - break; - } - } else - failed.clear(); -} - -void cYTCache::clearCompleted(MI_MOVIE_INFO *mi) -{ - OpenThreads::ScopedLock m_lock(mutex); - if (mi) { - for (std::vector::iterator it = completed.begin(); it != completed.end(); ++it) - if (compareMovieInfo(&(*it), mi)) { - completed.erase(it); - break; - } - } else - completed.clear(); -} - -void cYTCache::clearFailed(MI_MOVIE_INFO::miSource source) -{ - OpenThreads::ScopedLock m_lock(mutex); - for (std::vector::iterator it = failed.begin(); it != failed.end();) - if ((*it).source == source) - it = failed.erase(it); - else - ++it; -} - -void cYTCache::clearCompleted(MI_MOVIE_INFO::miSource source) -{ - OpenThreads::ScopedLock m_lock(mutex); - for (std::vector::iterator it = completed.begin(); it != completed.end();) - if ((*it).source == source) - it = completed.erase(it); - else - ++it; -} - -bool cYTCache::compareMovieInfo(MI_MOVIE_INFO *a, MI_MOVIE_INFO *b) -{ - return a->ytid == b->ytid && a->ytitag == b->ytitag && a->source == b->source; -} diff --git a/src/system/ytcache.h b/src/system/ytcache.h deleted file mode 100644 index 45873d38e..000000000 --- a/src/system/ytcache.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - ytcache.h -- cache youtube movies - - Copyright (C) 2013 martii - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef __YTCACHE_H__ -#define __YTCACHE_H__ - -#include -#include -#include - -#include -#include - -#include - -class cYTCache -{ - private: - pthread_t thread; - bool cancelled; - std::vector pending; - std::vector completed; - std::vector failed; - OpenThreads::Mutex mutex; - bool download(MI_MOVIE_INFO *mi); - std::string getName(MI_MOVIE_INFO *mi, std::string ext = "mp4"); - static void *downloadThread(void *arg); - static int curlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); - bool compareMovieInfo(MI_MOVIE_INFO *a, MI_MOVIE_INFO *b); - public: - double dltotal; - double dlnow; - time_t dlstart; - static cYTCache *getInstance(); - cYTCache(); - ~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(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT); - std::vector getCompleted(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT); - std::vector getFailed(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT); - std::vector getPending(MI_MOVIE_INFO::miSource = MI_MOVIE_INFO::YT, double *p_dltotal = NULL, double *p_dlnow = NULL, time_t *p_start = NULL); - void clearCompleted(MI_MOVIE_INFO *mi); - void clearFailed(MI_MOVIE_INFO *mi); - void clearCompleted(MI_MOVIE_INFO::miSource source = MI_MOVIE_INFO::YT); - void clearFailed(MI_MOVIE_INFO::miSource source = MI_MOVIE_INFO::YT); - bool getNameIfExists(std::string &fname, const std::string &id, int itag, std::string ext = ".jpg"); - bool isActive(void) { return (bool) thread; } -}; -#endif diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp deleted file mode 100644 index 86411a14d..000000000 --- a/src/system/ytparser.cpp +++ /dev/null @@ -1,741 +0,0 @@ -/* - Copyright (C) 2013 CoolStream International Ltd - - License: GPLv2 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include "settings.h" -#include "helpers.h" -#include "helpers-json.h" -#include "set_threadname.h" -#include -#include - -#include "ytparser.h" -#include "ytcache.h" - -#if LIBCURL_VERSION_NUM < 0x071507 -#include -#endif - -#define URL_TIMEOUT 60 -static int itags[] = { 37 /* 1080p MP4 */, 22 /* 720p MP4 */, 18 /* 270p/360p MP4 */, 0 }; - - -std::string cYTVideoUrl::GetUrl() -{ - std::string fullurl = url; - //fullurl += "&signature="; - //fullurl += sig; - return fullurl; -} - -void cYTVideoInfo::Dump() -{ - printf("id: %s\n", id.c_str()); - printf("author: %s\n", author.c_str()); - printf("title: %s\n", title.c_str()); - printf("duration: %d\n", duration); - //printf("description: %s\n", description.c_str()); - printf("urls: %d\n", (int)formats.size()); - for (yt_urlmap_iterator_t it = formats.begin(); it != formats.end(); ++it) { - printf("format %d type [%s] url %s\n", it->first, it->second.type.c_str(), it->second.GetUrl().c_str()); - } - printf("===================================================================\n"); -} - -std::string cYTVideoInfo::GetUrl(int *fmt, bool mandatory) -{ - int default_fmt = 0; - if (!*fmt) - fmt = &default_fmt; - - yt_urlmap_iterator_t it; - if (fmt) { - if ((it = formats.find(*fmt)) != formats.end()) { - return it->second.GetUrl(); - } - if (mandatory) { - *fmt = 0; - return ""; - } - } - - for (int *fmtp = itags; *fmtp; fmtp++) - if ((it = formats.find(*fmtp)) != formats.end()) { - *fmt = *fmtp; - return it->second.GetUrl(); - } - return ""; -} - -cYTFeedParser::cYTFeedParser() -{ - thumbnail_dir = "/tmp/ytparser"; - parsed = false; - feedmode = -1; - tquality = "mqdefault"; - max_results = 25; - concurrent_downloads = 2; - curl_handle = curl_easy_init(); -#ifdef YOUTUBE_DEV_ID - key = YOUTUBE_DEV_ID; -#else - key = g_settings.youtube_dev_id; -#endif -} - -cYTFeedParser::~cYTFeedParser() -{ - curl_easy_cleanup(curl_handle); -} - -size_t cYTFeedParser::CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data) -{ - if (size * nmemb > 0) { - std::string* pStr = (std::string*) data; - pStr->append((char*) ptr, nmemb); - } - return size*nmemb; -} - -bool cYTFeedParser::getUrl(std::string &url, std::string &answer, CURL *_curl_handle) -{ - if (!_curl_handle) - _curl_handle = curl_handle; - - curl_easy_setopt(_curl_handle, CURLOPT_URL, url.c_str()); - curl_easy_setopt(_curl_handle, CURLOPT_WRITEFUNCTION, &cYTFeedParser::CurlWriteToString); - curl_easy_setopt(_curl_handle, CURLOPT_FILE, (void *)&answer); - curl_easy_setopt(_curl_handle, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(_curl_handle, CURLOPT_TIMEOUT, URL_TIMEOUT); - curl_easy_setopt(_curl_handle, CURLOPT_NOSIGNAL, (long)1); - curl_easy_setopt(_curl_handle, CURLOPT_SSL_VERIFYPEER, false); - - if(!g_settings.softupdate_proxyserver.empty()) { - curl_easy_setopt(_curl_handle, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str()); - if(!g_settings.softupdate_proxyusername.empty()) { - std::string tmp = g_settings.softupdate_proxyusername + ":" + g_settings.softupdate_proxypassword; - curl_easy_setopt(_curl_handle, CURLOPT_PROXYUSERPWD, tmp.c_str()); - } - } - - char cerror[CURL_ERROR_SIZE] = {0}; - curl_easy_setopt(_curl_handle, CURLOPT_ERRORBUFFER, cerror); - - printf("try to get [%s] ...\n", url.c_str()); - CURLcode httpres = curl_easy_perform(_curl_handle); - - printf("https: res %d size %d\n", httpres, (int)answer.size()); - - if (httpres != 0 || answer.empty()) { - printf("error: %s\n", cerror); - return false; - } - return true; -} - -bool cYTFeedParser::DownloadUrl(std::string &url, std::string &file, CURL *_curl_handle) -{ - if (!_curl_handle) - _curl_handle = curl_handle; - - FILE * fp = fopen(file.c_str(), "wb"); - if (fp == NULL) { - perror(file.c_str()); - return false; - } - curl_easy_setopt(_curl_handle, CURLOPT_URL, url.c_str()); - curl_easy_setopt(_curl_handle, CURLOPT_WRITEFUNCTION, NULL); - curl_easy_setopt(_curl_handle, CURLOPT_FILE, fp); - curl_easy_setopt(_curl_handle, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(_curl_handle, CURLOPT_TIMEOUT, URL_TIMEOUT); - curl_easy_setopt(_curl_handle, CURLOPT_NOSIGNAL, (long)1); - curl_easy_setopt(_curl_handle, CURLOPT_SSL_VERIFYPEER, false); - - if(!g_settings.softupdate_proxyserver.empty()) { - curl_easy_setopt(_curl_handle, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str()); - if(!g_settings.softupdate_proxyusername.empty()) { - std::string tmp = g_settings.softupdate_proxyusername + ":" + g_settings.softupdate_proxypassword; - curl_easy_setopt(_curl_handle, CURLOPT_PROXYUSERPWD, tmp.c_str()); - } - } - - char cerror[CURL_ERROR_SIZE] = {0}; - curl_easy_setopt(_curl_handle, CURLOPT_ERRORBUFFER, cerror); - - printf("try to get [%s] ...\n", url.c_str()); - CURLcode httpres = curl_easy_perform(_curl_handle); - - double dsize; - curl_easy_getinfo(_curl_handle, CURLINFO_SIZE_DOWNLOAD, &dsize); - fclose(fp); - - printf("https: res %d size %g.\n", httpres, dsize); - - if (httpres != 0) { - printf("curl error: %s\n", cerror); - unlink(file.c_str()); - return false; - } - return true; -} - -void cYTFeedParser::decodeUrl(std::string &url) -{ - char * str = curl_easy_unescape(curl_handle, url.c_str(), 0, NULL); - if(str) - url = str; - curl_free(str); -} - -void cYTFeedParser::encodeUrl(std::string &txt) -{ - char * str = curl_easy_escape(curl_handle, txt.c_str(), txt.length()); - if(str) - txt = str; - curl_free(str); -} - -void cYTFeedParser::splitString(std::string &str, std::string delim, std::vector &strlist, int start) -{ - strlist.clear(); - std::string::size_type end = 0; - while ((end = str.find(delim, start)) != std::string::npos) { - strlist.push_back(str.substr(start, end - start)); - start = end + delim.size(); - } - strlist.push_back(str.substr(start)); -} - -void cYTFeedParser::splitString(std::string &str, std::string delim, std::map &strmap, int start) -{ - std::string::size_type end = 0; - if ((end = str.find(delim, start)) != std::string::npos) { - strmap[str.substr(start, end - start)] = str.substr(end - start + delim.size()); - } -} - -bool cYTFeedParser::saveToFile(const char * name, std::string str) -{ - FILE * fp = fopen(name, "w+"); - if (fp) { - fprintf(fp, "%s", str.c_str()); - fclose(fp); - return false; - } - printf("cYTFeedParser::saveToFile: failed to open %s\n", name); - return false; -} - -std::string cYTFeedParser::getXmlName(xmlNodePtr node) -{ - std::string result; - const char * name = xmlGetName(node); - if (name) - result = name; - return result; -} - -std::string cYTFeedParser::getXmlAttr(xmlNodePtr node, const char * attr) -{ - std::string result; - const char * value = xmlGetAttribute(node, attr); - if (value) - result = value; - return result; -} - -std::string cYTFeedParser::getXmlData(xmlNodePtr node) -{ - std::string result; - const char * value = xmlGetData(node); - if (value) - result = value; - return result; -} - -bool cYTFeedParser::parseFeedJSON(std::string &answer) -{ - std::string errMsg = ""; - Json::Value root; - - std::ostringstream ss; - std::ifstream fh(curfeedfile.c_str(),std::ifstream::in); - ss << fh.rdbuf(); - std::string filedata = ss.str(); - - bool parsedSuccess = parseJsonFromString(filedata, &root, NULL); - - if(!parsedSuccess) - { - parsedSuccess = parseJsonFromString(answer, &root, &errMsg); - } - - if(!parsedSuccess) - { - printf("Failed to parse JSON\n"); - printf("%s\n", errMsg.c_str()); - return false; - } - - next.clear(); - prev.clear(); - //TODO - total.clear(); - start.clear(); - - next = root.get("nextPageToken", "").asString(); - prev = root.get("prevPageToken", "").asString(); - - cYTVideoInfo vinfo; - Json::Value elements = root["items"]; - for(unsigned int i=0; igetText(LOCALE_MOVIEBROWSER_SCAN_FOR_VIDEOS)); -#ifdef DEBUG_PARSER - printf("=========================================================\n"); - printf("Element %d in elements\n", i); - printf("%s\n", elements[i]); -#endif - if(elements[i]["id"].type() == Json::objectValue) { - vinfo.id = elements[i]["id"].get("videoId", "").asString(); - } - else if(elements[i]["id"].type() == Json::stringValue) { - vinfo.id = elements[i].get("id", "").asString(); - } - - vinfo.title = elements[i]["snippet"].get("title", "").asString(); - vinfo.description = elements[i]["snippet"].get("description", "").asString(); - vinfo.published = elements[i]["snippet"].get("publishedAt", "").asString().substr(0, 10); - std::string thumbnail = elements[i]["snippet"]["thumbnails"]["default"].get("url", "").asString(); - // save thumbnail "default", if "high" not found - vinfo.thumbnail = elements[i]["snippet"]["thumbnails"]["high"].get("url", thumbnail).asString(); - vinfo.author = elements[i]["snippet"].get("channelTitle", "unkown").asString(); - vinfo.category = ""; - parseFeedDetailsJSON(&vinfo); - -#ifdef DEBUG_PARSER - printf("prevPageToken: %s\n", prev.c_str()); - printf("nextPageToken: %s\n", next.c_str()); - printf("vinfo.id: %s\n", vinfo.id.c_str()); - printf("vinfo.description: %s\n", vinfo.description.c_str()); - printf("vinfo.published: %s\n", vinfo.published.c_str()); - printf("vinfo.title: %s\n", vinfo.title.c_str()); - printf("vinfo.thumbnail: %s\n", vinfo.thumbnail.c_str()); -#endif - if (!vinfo.id.empty()) { - vinfo.ret = false; - videos.push_back(vinfo); - } - } - - GetVideoUrls(); - - std::vector::iterator pos = videos.begin(); - while (pos != videos.end()) - if ((*pos).ret) - ++pos; - else - pos = videos.erase(pos); - - parsed = !videos.empty(); - return parsed; -} - -bool cYTFeedParser::parseFeedDetailsJSON(cYTVideoInfo* vinfo) -{ - vinfo->duration = 0; - // See at https://developers.google.com/youtube/v3/docs/videos - std::string url = "https://www.googleapis.com/youtube/v3/videos?id=" + vinfo->id + "&part=contentDetails&key=" + key; - std::string answer; - if (!getUrl(url, answer)) - return false; - - std::string errMsg = ""; - Json::Value root; - bool parsedSuccess = parseJsonFromString(answer, &root, &errMsg); - if (!parsedSuccess) { - printf("Failed to parse JSON\n"); - printf("%s\n", errMsg.c_str()); - return false; - } - - - Json::Value elements = root["items"]; - std::string duration = elements[0]["contentDetails"].get("duration", "").asString(); - if (duration.find("PT") != std::string::npos) { - int h=0, m=0, s=0; - if (duration.find("H") != std::string::npos) { - sscanf(duration.c_str(), "PT%dH%dM%dS", &h, &m, &s); - } - else if (duration.find("M") != std::string::npos) { - sscanf(duration.c_str(), "PT%dM%dS", &m, &s); - } - else if (duration.find("S") != std::string::npos) { - sscanf(duration.c_str(), "PT%dS", &s); - } -// printf(">>>>> duration: %s, h: %d, m: %d, s: %d\n", duration.c_str(), h, m, s); - vinfo->duration = h*3600 + m*60 + s; - } - return true; -} - -bool cYTFeedParser::supportedFormat(int fmt) -{ - for (int *fmtp = itags; *fmtp; fmtp++) - if (*fmtp == fmt) - return true; - return false; -} - -bool cYTFeedParser::decodeVideoInfo(std::string &answer, cYTVideoInfo &vinfo) -{ - bool ret = false; -#if 0 - std::string infofile = thumbnail_dir; - infofile += "/"; - infofile += vinfo.id; - infofile += ".txt"; - saveToFile(infofile.c_str(), answer); -#endif - - //FIXME check expire - std::vector ulist; - - // Extract player_response - std::string::size_type player_resp_start = answer.find("player_response="); - if (player_resp_start == std::string::npos) { - printf("player_response not found\n"); - return false; - } - - player_resp_start = answer.find("=", player_resp_start) + 1; - std::string::size_type player_resp_end = answer.find("&", player_resp_start); - if (player_resp_end == std::string::npos) { - player_resp_end = answer.length(); - } - std::string player_response = answer.substr(player_resp_start, player_resp_end - player_resp_start); - decodeUrl(player_response); - - // Load player_response as json - Json::Value root; - if (!parseJsonFromString(player_response, &root, NULL)) { - printf("Decoding player_response failed\n"); - return false; - } - - const Json::Value streamingData = root["streamingData"]; - if (!streamingData) { - printf("streamingData element not present\n"); - return false; - } - - const Json::Value formats = streamingData["formats"]; - if (!formats) { - printf("formats element not present\n"); - return false; - } - - for (auto it = formats.begin(); it != formats.end(); ++it) { - const Json::Value format = *it; - - int id = format["itag"].asInt(); - std::string quality = format["quality"].asString(); - std::string url; - - if (!format["url"].empty()) { - url = format["url"].asString(); - } else if (!format["cipher"].empty()) { - // FIXME add support for cipher (is it still used or was it replaced by signatureCipher?) - printf("cipher unsupported: %s\n", format["cipher"].asCString()); - continue; - } else if (!format["signatureCipher"].empty()) { - // FIXME add support for signatureCipher - printf("signatureCipher unsupported: %s\n", format["signatureCipher"].asCString()); - continue; - } else { - printf("Unable to find url\n"); - continue; - } -#ifdef DEBUG_PARSER - printf("%d: %s - %s\n", id, quality.c_str(), url.c_str()); -#endif - - cYTVideoUrl yurl; - if (supportedFormat(id) && !url.empty()) { - yurl.quality = quality; - yurl.url = url; - yurl.type = format["mimeType"].asString(); - vinfo.formats.insert(yt_urlmap_pair_t(id, yurl)); - ret = true; - } - } - - return ret; -} - -bool cYTFeedParser::ParseFeed(std::string &url) -{ - videos.clear(); - - std::string answer; - curfeedfile = thumbnail_dir; - curfeedfile += "/"; - curfeedfile += curfeed; - curfeedfile += ".xml"; -#ifdef CACHE_FILES - if(!DownloadUrl(url, cfile)) - return false; -#else - if (!getUrl(url, answer)) - return false; -#endif - return parseFeedJSON(answer); -} - -bool cYTFeedParser::ParseFeed(yt_feed_mode_t mode, std::string search, std::string vid, yt_feed_orderby_t orderby) -{ - std::string answer; - std::string url = "https://www.googleapis.com/youtube/v3/search?"; - bool append_res = true; - std::string trailer; - if (mode < FEED_LAST) { - switch(mode) { - //FIXME APIv3: we dont have the parameter "time". - case MOST_POPULAR: - default: - //trailer = "&time=today"; - curfeed = "&chart=mostPopular"; - break; - case MOST_POPULAR_ALL_TIME: - curfeed = "&chart=mostPopular"; - break; - } - url = "https://www.googleapis.com/youtube/v3/videos?part=snippet"; - if (!region.empty()) { - url += "®ionCode="; - url += region; - } - url += curfeed; - } - else if (mode == NEXT) { - if (next.empty()) - return false; - url = nextprevurl; - url += "&pageToken="; - url += next; - append_res = false; - } - else if (mode == PREV) { - if (prev.empty()) - return false; - url = nextprevurl; - url += "&pageToken="; - url += prev; - append_res = false; - } - else if (mode == RELATED) { - if (vid.empty()) - return false; - url = "https://www.googleapis.com/youtube/v3/videos/"; - url += vid; - url += "/related?"; - } - else if (mode == SEARCH) { - if (search.empty()) - return false; - encodeUrl(search); - url = "https://www.googleapis.com/youtube/v3/search?q="; - url += search; - url += "&part=snippet"; - //FIXME locale for "title" and "videoCount" - const char *orderby_values[] = { "date","relevance","viewCount","rating","title","videoCount"}; - url += "&order=" + std::string(orderby_values[orderby & 3]); - } - - feedmode = mode; - if (append_res) { - url += "&maxResults="; - char res[10]; - sprintf(res, "%d", max_results); - url+= res; - url += "&key=" + key; - nextprevurl = url; - } - - return ParseFeed(url); -} - -bool cYTFeedParser::ParseVideoInfo(cYTVideoInfo &vinfo, CURL *_curl_handle) -{ - bool ret = false; - std::vector estr; - estr.push_back("&el=embedded"); - estr.push_back("&el=vevo"); - estr.push_back("&el=detailpage"); - - for (unsigned i = 0; i < estr.size(); i++) { - std::string vurl = "https://www.youtube.com/get_video_info?video_id="; - vurl += vinfo.id; - vurl += estr[i]; - vurl += "&ps=default&eurl=&gl=US&hl=en&html5=1"; - printf("cYTFeedParser::ParseVideoInfo: get [%s]\n", vurl.c_str()); - std::string answer; - if (!getUrl(vurl, answer, _curl_handle)) - continue; - ret = decodeVideoInfo(answer, vinfo); - if (ret) - break; - } - vinfo.ret = ret; - return ret; -} - -void *cYTFeedParser::DownloadThumbnailsThread(void *arg) -{ - set_threadname("YT::DownloadThumbnails"); - bool ret = true; - cYTFeedParser *caller = (cYTFeedParser *)arg; - CURL *c = curl_easy_init(); - unsigned int i; - do { - OpenThreads::ScopedLock m_lock(caller->mutex); - i = caller->worker_index++; - } while (i < caller->videos.size() && ((ret &= caller->DownloadThumbnail(caller->videos[i], c)) || true)); - curl_easy_cleanup(c); - pthread_exit(&ret); -} - -bool cYTFeedParser::DownloadThumbnail(cYTVideoInfo &vinfo, CURL *_curl_handle) -{ - if (!_curl_handle) - _curl_handle = curl_handle; - bool found = false; - if (!vinfo.thumbnail.empty()) { - std::string fname = thumbnail_dir + "/" + vinfo.id + ".jpg"; - found = !access(fname, F_OK); - if (!found) { - for (int *fmtp = itags; *fmtp && !found; fmtp++) - found = cYTCache::getInstance()->getNameIfExists(fname, vinfo.id, *fmtp); - } - if (!found) - found = DownloadUrl(vinfo.thumbnail, fname, _curl_handle); - if (found) - vinfo.tfile = fname; - } - return found; -} - -bool cYTFeedParser::DownloadThumbnails() -{ - bool ret = true; - if (mkdir(thumbnail_dir.c_str(), 0755) && errno != EEXIST) { - perror(thumbnail_dir.c_str()); - return false; - } - unsigned int max_threads = concurrent_downloads; - if (videos.size() < max_threads) - max_threads = videos.size(); - pthread_t ta[max_threads]; - worker_index = 0; - for (unsigned i = 0; i < max_threads; i++) - pthread_create(&ta[i], NULL, cYTFeedParser::DownloadThumbnailsThread, this); - for (unsigned i = 0; i < max_threads; i++) { - void *r; - pthread_join(ta[i], &r); - ret &= *((bool *)r); - } - return ret; -} - -void *cYTFeedParser::GetVideoUrlsThread(void *arg) -{ - set_threadname("YT::GetVideoUrls"); - int ret = 0; - cYTFeedParser *caller = (cYTFeedParser *)arg; - CURL *c = curl_easy_init(); - unsigned int i; - do { - OpenThreads::ScopedLock m_lock(caller->mutex); - i = caller->worker_index++; - } while (i < caller->videos.size() && ((ret |= caller->ParseVideoInfo(caller->videos[i], c)) || true)); - curl_easy_cleanup(c); - pthread_exit(&ret); -} - -bool cYTFeedParser::GetVideoUrls() -{ - int ret = 0; - unsigned int max_threads = concurrent_downloads; - if (videos.size() < max_threads) - max_threads = videos.size(); - pthread_t ta[max_threads]; - worker_index = 0; - for (unsigned i = 0; i < max_threads; i++) - pthread_create(&ta[i], NULL, cYTFeedParser::GetVideoUrlsThread, this); - for (unsigned i = 0; i < max_threads; i++) { - void *r; - pthread_join(ta[i], &r); - ret |= *((int *)r); - } - return ret; -} - -void cYTFeedParser::Cleanup(bool delete_thumbnails) -{ - printf("cYTFeedParser::Cleanup: %d videos\n", (int)videos.size()); - if (delete_thumbnails) { - for (unsigned i = 0; i < videos.size(); i++) { - unlink(videos[i].tfile.c_str()); - } - } - unlink(curfeedfile.c_str()); - videos.clear(); - parsed = false; - feedmode = -1; -} - -void cYTFeedParser::SetThumbnailDir(std::string &_thumbnail_dir) -{ - thumbnail_dir = _thumbnail_dir; -} - -void cYTFeedParser::Dump() -{ - printf("feed: %d videos\n", (int)videos.size()); - for (unsigned i = 0; i < videos.size(); i++) - videos[i].Dump(); -} diff --git a/src/system/ytparser.h b/src/system/ytparser.h deleted file mode 100644 index dcc8f1322..000000000 --- a/src/system/ytparser.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (C) 2013 CoolStream International Ltd - - License: GPLv2 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef __YT_PARSER__ -#define __YT_PARSER__ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -class cYTVideoUrl -{ - public: - std::string quality; - std::string type; - std::string sig; - std::string url; - - std::string GetUrl(); -}; - -typedef std::map yt_urlmap_t; -typedef std::pair yt_urlmap_pair_t; -typedef yt_urlmap_t::iterator yt_urlmap_iterator_t; - -class cYTVideoInfo -{ - public: - std::string id; - std::string title; - std::string author; - std::string description; - std::string category; - std::string thumbnail; - std::string tfile; - std::string published; - int duration; - yt_urlmap_t formats; - bool ret; - - void Dump(); - std::string GetUrl(int *fmt = NULL, bool mandatory = true); - -}; - -typedef std::vector yt_video_list_t; - -class cYTFeedParser : public CProgressSignals -{ - private: - std::string error; - std::string thumbnail_dir; - std::string curfeed; - std::string curfeedfile; - std::string tquality; // thumbnail size - std::string region; // more results - std::string next; // next results - std::string prev; // prev results - std::string start; // start index - std::string total; // total results - std::string nextprevurl; // url for next/prev - std::string key; // youtube dev id - - int feedmode; - int max_results; - int concurrent_downloads; - bool parsed; - yt_video_list_t videos; - - std::string getXmlName(xmlNodePtr node); - std::string getXmlAttr(xmlNodePtr node, const char * attr); - std::string getXmlData(xmlNodePtr node); - - CURL *curl_handle; - OpenThreads::Mutex mutex; - int worker_index; - static void* GetVideoUrlsThread(void*); - static void* DownloadThumbnailsThread(void*); - - static size_t CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data); - void encodeUrl(std::string &txt); - void decodeUrl(std::string &url); - static void splitString(std::string &str, std::string delim, std::vector &strlist, int start = 0); - static void splitString(std::string &str, std::string delim, std::map &strmap, int start = 0); - static bool saveToFile(const char * name, std::string str); - bool getUrl(std::string &url, std::string &answer, CURL *_curl_handle = NULL); - bool DownloadUrl(std::string &url, std::string &file, CURL *_curl_handle = NULL); - bool parseFeedJSON(std::string &answer); - bool parseFeedDetailsJSON(cYTVideoInfo* vinfo); - bool decodeVideoInfo(std::string &answer, cYTVideoInfo &vinfo); - bool supportedFormat(int fmt); - bool ParseFeed(std::string &url); - public: - enum yt_feed_mode_t - { - MOST_POPULAR, - MOST_POPULAR_ALL_TIME, - FEED_LAST, - NEXT, - PREV, - RELATED, - 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 = "", 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(); - bool DownloadThumbnails(); - void Dump(); - void Cleanup(bool delete_thumbnails = false); - - yt_video_list_t &GetVideoList() { return videos; } - bool Parsed() { return parsed; } - int GetFeedMode() { return feedmode; } - bool HaveNext(void) { return !next.empty(); } - bool HavePrev(void) { return !prev.empty(); } - std::string GetTotal(void) { return total; } - std::string GetError(void) { return error; } - - void SetRegion(std::string reg) { region = reg; } - void SetMaxResults(int count) { max_results = count; } - void SetConcurrentDownloads(int count) { concurrent_downloads = count; } - void SetThumbnailDir(std::string &_thumbnail_dir); -}; - -#endif