From 515a2cfa39dd06a7cba81d0295281f384534f24c Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 3 May 2021 23:16:52 +0200 Subject: [PATCH] epgview: allow to save imdb/tmdb poster with g_settings.mbkey_cover Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c0ea337174dc7340e109aa94d9684f7a1861a0da Author: vanhofen Date: 2021-05-03 (Mon, 03 May 2021) Origin message was: ------------------ - epgview: allow to save imdb/tmdb poster with g_settings.mbkey_cover ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/locale/deutsch.locale | 3 +- data/locale/english.locale | 3 +- src/gui/epgview.cpp | 80 +++++++++++++++++++------------------ src/gui/mdb-imdb.h | 3 +- src/gui/moviebrowser/mb.cpp | 2 +- src/system/locals.h | 3 +- src/system/locals_intern.h | 3 +- 7 files changed, 52 insertions(+), 45 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 867d6b748..130d2832c 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1083,7 +1083,6 @@ imdb.data_votes Stimmen imdb.data_website Webseite imdb.data_writer Drehbuchautor imdb.info IMDb-Info -imdb.info_save Bild speichern imdb.read_data Suche IMDb-Daten ... inetradio.name Internetradio inetradio_autostart Internetradio Auto-Start @@ -1287,6 +1286,8 @@ mbkey.copy_several Film kopieren und teilen mbkey.cover Filmcover erzeugen/löschen mbkey.cut Film schneiden mbkey.truncate Film kürzen +mdb.save_poster Bild speichern +mdb.save_poster_hint Bild speichern mit %s menu.back Zurück menu.cancel Abbrechen menu.hint_a_pic Konfigurieren Sie den Audioplayer und den Bildbetrachter diff --git a/data/locale/english.locale b/data/locale/english.locale index 7c4dd863c..ebea12996 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1083,7 +1083,6 @@ imdb.data_votes Votes imdb.data_website Website imdb.data_writer Screenplay author imdb.info IMDb-Info -imdb.info_save save Cover imdb.read_data Search IMDb data ... inetradio.name Internetradio inetradio_autostart Internetradio auto-start @@ -1287,6 +1286,8 @@ mbkey.copy_several Copy and split movie mbkey.cover Create/remove movie cover mbkey.cut Cut movie mbkey.truncate Truncate movie +mdb.save_poster Save poster +mdb.save_poster_hint Save poster with %s menu.back Back menu.cancel Cancel menu.hint_a_pic Configure audio player and picture viewer diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 84bed94b9..59b358c25 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -288,6 +288,14 @@ void CEpgData::showText(int startPos, int ypos, bool has_cover, bool fullClear) cover_offset = 0; frameBuffer->paintBoxRel(sx, y, ox-SCROLLBAR_WIDTH, sb, COL_MENUCONTENT_PLUS_0); // background of the text box } + /* FIXME + else + { + char hint[1024]; + snprintf(hint, sizeof(hint), g_Locale->getText(LOCALE_MDB_SAVE_POSTER_HINT), g_RCInput->getKeyName((neutrino_msg_t) g_settings.mbkey_cover)); + font->RenderString(sx+OFFSET_INNER_MID, y+OFFSET_INNER_MID+cover_height+OFFSET_INNER_MID+font->getHeight(), cover_width, hint, COL_MENUCONTENT_TEXT); + } + */ } // recalculate @@ -1207,30 +1215,6 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start else ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NODETAILED, CMsgBox::mbrOk , CMsgBox::mbrOk); } - else if (imdb_active && imdb->hasPoster()) - { - imdb_active = false; - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_IMDB_INFO_SAVE); - hintBox->paint(); - - std::string picname; - if (mp_info) - { - size_t _pos; - if ((_pos = movie_filename.rfind(".")) != std::string::npos) - picname = movie_filename.substr(0, _pos) + ".jpg"; - } - else - picname = CMDBTools::getInstance()->getFilename(channel, epgData.eventID); - - CFileHelpers fh; - if (!fh.copyFile(imdb->posterfile.c_str(), picname.c_str(), 0644)) - perror( "IMDb: error copy file" ); - - sleep(2); - hintBox->hide(); - showTimerEventBar(true, !mp_info && isCurrentEPG(channel_id), mp_info); //show buttons - } else { imdb_active = false; @@ -1399,6 +1383,38 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start } else loop = false; } + else if (msg == (neutrino_msg_t) g_settings.mbkey_cover) + { + std::string poster(""); + + if (imdb_active && imdb->hasPoster()) + poster = imdb->getPoster(); + else if (tmdb_active && tmdb->hasPoster()) + poster = tmdb->getPoster(); + + if (!poster.empty()) + { + CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_MDB_SAVE_POSTER); + hintBox.paint(); + + std::string picname; + if (mp_info) + { + size_t _pos; + if ((_pos = movie_filename.rfind(".")) != std::string::npos) + picname = movie_filename.substr(0, _pos) + ".jpg"; + } + else + picname = CMDBTools::getInstance()->getFilename(channel, epgData.eventID); + + CFileHelpers fh; + if (!fh.copyFile(poster.c_str(), picname.c_str(), 0644)) + perror( "IMDb: error copy file" ); + + sleep(2); + hintBox.hide(); + } + } else if (CNeutrinoApp::getInstance()->listModeKey(msg)) { if (!call_fromfollowlist) { g_RCInput->postMsg (msg, 0); @@ -1655,21 +1671,9 @@ void CEpgData::showTimerEventBar (bool pshow, bool adzap, bool mp_info) adzap_button += g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE); } - // check imdb button if (g_settings.omdb_enabled) - { - if (imdb_active) - { - EpgButtons[UsedButtons][1].button = (imdb->hasPoster()) ? NEUTRINO_ICON_BUTTON_GREEN : NEUTRINO_ICON_BUTTON_DUMMY_SMALL; - EpgButtons[UsedButtons][1].locale = LOCALE_IMDB_INFO_SAVE; - } - else - { - EpgButtons[UsedButtons][1].button = NEUTRINO_ICON_BUTTON_GREEN; - EpgButtons[UsedButtons][1].locale = LOCALE_IMDB_INFO; - } - } + EpgButtons[UsedButtons][1].button = NEUTRINO_ICON_BUTTON_GREEN; else EpgButtons[UsedButtons][1].button = NEUTRINO_ICON_BUTTON_DUMMY_SMALL; @@ -1680,9 +1684,7 @@ void CEpgData::showTimerEventBar (bool pshow, bool adzap, bool mp_info) EpgButtons[UsedButtons][2].button = NEUTRINO_ICON_BUTTON_DUMMY_SMALL; if (mp_info) - { ::paintButtons(x, y, w, MaxButtons, EpgButtons[MP_BUTTONS], w, h); - } else { // check followscreenings button diff --git a/src/gui/mdb-imdb.h b/src/gui/mdb-imdb.h index 938de530e..2c7d688a9 100644 --- a/src/gui/mdb-imdb.h +++ b/src/gui/mdb-imdb.h @@ -42,6 +42,8 @@ class CIMDB std::string parseFile(std::string search1, std::string search2, const char *file, std::string firstline = "", int line_offset = 0); std::map m; + std::string posterfile; + void initMap(std::map &my); public: @@ -56,7 +58,6 @@ class CIMDB std::string search_outfile; std::string search_error; std::string imdb_outfile; - std::string posterfile; int getMovieDetails(const std::string &epgTitle); void cleanup(); diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index e3e416d3e..e6f71d10c 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -877,7 +877,7 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey) poster = m_movieSelectionHandler->file.Name.substr(0, pos); poster += ".jpg"; CFileHelpers fh; - if (fh.copyFile(imdb->posterfile.c_str(), poster.c_str(), 0644)) + if (fh.copyFile(imdb->getPoster().c_str(), poster.c_str(), 0644)) printf("* poster: %s\n", poster.c_str()); else printf("* poster: copy error\n"); diff --git a/src/system/locals.h b/src/system/locals.h index d54fdb118..3bec21b65 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1110,7 +1110,6 @@ typedef enum LOCALE_IMDB_DATA_WEBSITE, LOCALE_IMDB_DATA_WRITER, LOCALE_IMDB_INFO, - LOCALE_IMDB_INFO_SAVE, LOCALE_IMDB_READ_DATA, LOCALE_INETRADIO_NAME, LOCALE_INETRADIO_AUTOSTART, @@ -1314,6 +1313,8 @@ typedef enum LOCALE_MBKEY_COVER, LOCALE_MBKEY_CUT, LOCALE_MBKEY_TRUNCATE, + LOCALE_MDB_SAVE_POSTER, + LOCALE_MDB_SAVE_POSTER_HINT, LOCALE_MENU_BACK, LOCALE_MENU_CANCEL, LOCALE_MENU_HINT_A_PIC, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 57cd49873..af5a22b5a 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1110,7 +1110,6 @@ const char * locale_real_names[] = "imdb.data_website", "imdb.data_writer", "imdb.info", - "imdb.info_save", "imdb.read_data", "inetradio.name", "inetradio_autostart", @@ -1314,6 +1313,8 @@ const char * locale_real_names[] = "mbkey.cover", "mbkey.cut", "mbkey.truncate", + "mdb.save_poster", + "mdb.save_poster_hint", "menu.back", "menu.cancel", "menu.hint_a_pic",