From 43fe513bb18381a02a9d61a08a4025bcc9a0271a Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Mon, 5 Sep 2022 01:01:51 -0500 Subject: [PATCH] Added trailer link, added custom errors, updated keybinding --- plugins/movie_tv_info/movie_tv_info.glade | 57 ++++++++++++------- plugins/movie_tv_info/plugin.py | 36 ++++++++++-- .../solarfm-0.0.1/SolarFM/solarfm/app.py | 10 +++- .../usr/share/solarfm/key-bindings.json | 2 +- 4 files changed, 77 insertions(+), 28 deletions(-) diff --git a/plugins/movie_tv_info/movie_tv_info.glade b/plugins/movie_tv_info/movie_tv_info.glade index d32ab8c..3c8887e 100644 --- a/plugins/movie_tv_info/movie_tv_info.glade +++ b/plugins/movie_tv_info/movie_tv_info.glade @@ -2,6 +2,11 @@ + + True + False + gtk-media-play + 1 100 @@ -115,10 +120,22 @@ True False 4 - 2 + 3 2 12 6 + + + Trailer + True + True + True + image1 + + + 2 + + True @@ -126,10 +143,27 @@ <b>File _Name:</b> True True - file_name 0 + 1 + 2 + GTK_FILL + + + + + + True + False + <b>_Location:</b> + True + True + 0 + + + 2 + 3 GTK_FILL @@ -143,23 +177,8 @@ 1 2 - - - - - - True - False - <b>_Location:</b> - True - True - file_location - 0 - - 1 2 - GTK_FILL @@ -172,8 +191,8 @@ 1 2 - 1 - 2 + 2 + 3 GTK_FILL diff --git a/plugins/movie_tv_info/plugin.py b/plugins/movie_tv_info/plugin.py index e9d1114..67f01c5 100644 --- a/plugins/movie_tv_info/plugin.py +++ b/plugins/movie_tv_info/plugin.py @@ -37,14 +37,15 @@ class Plugin: self._dialog = None self._thumbnail_preview_img = None self._tmdb = scraper.get_tmdb_scraper() + self._state = None self._overview = None self._file_name = None self._file_location = None - self._state = None + self._trailer_link = None - self._event_system = None - self._event_sleep_time = .5 - self._event_message = None + self._event_system = None + self._event_sleep_time = .5 + self._event_message = None def get_ui_element(self): @@ -69,6 +70,7 @@ class Plugin: self._file_location = self._builder.get_object("file_location") self._thumbnail_preview_img = self._builder.get_object("thumbnail_preview_img") self._file_hash = self._builder.get_object("file_hash") + self._trailer_link = self._builder.get_object("trailer_link") button = Gtk.Button(label=self.name) button.connect("button-release-event", self._show_info_page) @@ -102,13 +104,14 @@ class Plugin: self._thumbnailer_dialog.hide() def _set_ui_data(self): - title, path, video_data = self.get_video_data() + title, path, trailer, video_data = self.get_video_data() keys = video_data.keys() if video_data else None overview_text = video_data["overview"] if video_data else f"...NO {self.name.upper()} DATA..." self.set_text_data(title, path, overview_text) self.set_thumbnail(video_data) if video_data else ... + self.set_trailer_link(trailer) print(video_data["videos"]) if not keys in ("", None) and "videos" in keys else ... @@ -124,15 +127,31 @@ class Plugin: endIndex = _title.index(')') date = title[startIndex:endIndex] except Exception as e: + print(repr(e)) title = _title date = None try: + video_data = self._tmdb.search(title, date)[0] + video_id = video_data["id"] + try: + results = self._tmdb.tmdbapi.get_movie(str(video_id), append_to_response="videos")["videos"]["results"] + for result in results: + if "YouTube" in result["site"]: + trailer = result["key"] + + if not trailer: + raise Exception("No key found. Defering to none...") + except Exception as e: + print("No trailer found...") + trailer = None + except Exception as e: + print(repr(e)) video_data = None - return title, path, video_data + return title, path, trailer, video_data def set_text_data(self, title, path, overview_text): @@ -164,6 +183,11 @@ class Plugin: else: print('Cover Background Image Couldn\'t be retreived...') + def set_trailer_link(self, trailer): + if trailer: + self._trailer_link.set_uri(f"https://www.youtube.com/watch?v={trailer}") + + def wait_for_fm_message(self): diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/app.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/app.py index a0e36e9..18f1374 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/app.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/app.py @@ -10,6 +10,12 @@ from utils.settings import Settings from core.controller import Controller +class App_Launch_Exception(Exception): + ... + +class Controller_Start_Exceptio(Exception): + ... + class Application(IPCServer): """ Create Settings and Controller classes. Bind signal to Builder. Inherit from Builtins to bind global methods and classes. """ @@ -32,7 +38,7 @@ class Application(IPCServer): message = f"FILE|{args.new_tab}" self.send_ipc_message(message) - raise Exception("IPC Server Exists: Will send path(s) to it and close...\nNote: If no fm exists, remove /tmp/solarfm-ipc.sock") + raise App_Launch_Exception("IPC Server Exists: Will send path(s) to it and close...\nNote: If no fm exists, remove /tmp/solarfm-ipc.sock") settings = Settings() @@ -40,7 +46,7 @@ class Application(IPCServer): controller = Controller(args, unknownargs, settings) if not controller: - raise Exception("Controller exited and doesn't exist...") + raise Controller_Start_Exceptio("Controller exited and doesn't exist...") # Gets the methods from the classes and sets to handler. # Then, builder connects to any signals it needs. diff --git a/user_config/usr/share/solarfm/key-bindings.json b/user_config/usr/share/solarfm/key-bindings.json index 9c3c264..bd36c53 100644 --- a/user_config/usr/share/solarfm/key-bindings.json +++ b/user_config/usr/share/solarfm/key-bindings.json @@ -8,7 +8,7 @@ "r"], "delete_files" : ["Delete", "d"], - "tggl_top_main_menubar" : "", + "tggl_top_main_menubar" : "h", "trash_files" : "t", "tear_down" : "q", "go_up" : "Up",