Updated VOD Thumbnailer, added icon gen logic
This commit is contained in:
@@ -35,6 +35,7 @@ class Plugin:
|
||||
self._builder = None
|
||||
self._thumbnailer_dialog = None
|
||||
self._thumbnail_preview_img = None
|
||||
self._scrub_step = None
|
||||
self._file_name = None
|
||||
self._file_location = None
|
||||
self._file_hash = None
|
||||
@@ -63,6 +64,7 @@ class Plugin:
|
||||
self._builder.connect_signals(handlers)
|
||||
|
||||
self._thumbnailer_dialog = self._builder.get_object("thumbnailer_dialog")
|
||||
self._scrub_step = self._builder.get_object("scrub_step")
|
||||
self._file_name = self._builder.get_object("file_name")
|
||||
self._file_location = self._builder.get_object("file_location")
|
||||
self._thumbnail_preview_img = self._builder.get_object("thumbnail_preview_img")
|
||||
@@ -99,40 +101,44 @@ class Plugin:
|
||||
self._state = state
|
||||
self._set_ui_data()
|
||||
response = self._thumbnailer_dialog.run()
|
||||
if response in [Gtk.ResponseType.CANCEL, Gtk.ResponseType.DELETE_EVENT]:
|
||||
if response in [Gtk.ResponseType.CLOSE, Gtk.ResponseType.DELETE_EVENT]:
|
||||
self._thumbnailer_dialog.hide()
|
||||
|
||||
|
||||
def _regenerate_thumbnail(self, widget=None, eve=None):
|
||||
print("Regenerating thumbnail...")
|
||||
file = self._file_name.get_text()
|
||||
dir = self._file_location.get_text()
|
||||
file_hash = self._file_hash.get_text()
|
||||
scrub_percent = int(self._scrub_step.get_value())
|
||||
file = self._file_name.get_text()
|
||||
dir = self._file_location.get_text()
|
||||
file_hash = self._file_hash.get_text()
|
||||
hash_img_pth = f"{self._state.tab.ABS_THUMBS_PTH}/{file_hash}.jpg"
|
||||
|
||||
hash_img_pth = f"{self._state.tab.ABS_THUMBS_PTH}/{file_hash}.jpg"
|
||||
try:
|
||||
if os.path.isfile(hash_img_pth):
|
||||
os.remove(hash_img_pth)
|
||||
os.remove(hash_img_pth) if os.path.isfile(hash_img_pth) else ...
|
||||
|
||||
img_pixbuf = self._state.tab.create_icon(dir, file)
|
||||
self._thumbnail_preview_img.set_from_pixbuf(img_pixbuf)
|
||||
self._state.tab.create_thumbnail(dir, file, f"{scrub_percent}%")
|
||||
preview_pixbuf = GdkPixbuf.Pixbuf.new_from_file(hash_img_pth)
|
||||
self._thumbnail_preview_img.set_from_pixbuf(preview_pixbuf)
|
||||
|
||||
img_pixbuf = self._state.tab.create_scaled_image(hash_img_pth)
|
||||
tree_pth = self._state.icon_grid.get_selected_items()[0]
|
||||
itr = self._state.store.get_iter(tree_pth)
|
||||
pixbuff = self._state.store.get(itr, 0)[0]
|
||||
self._state.store.set(itr, 0, img_pixbuf)
|
||||
except Exception as e:
|
||||
print(repr(e))
|
||||
print("Couldn't regenerate thumbnail!")
|
||||
|
||||
def _use_selected_thumbnail(self, widget=None, eve=None):
|
||||
print("_use_selected_thumbnail stub...")
|
||||
|
||||
|
||||
def _set_ui_data(self):
|
||||
uri = self._state.selected_files[0]
|
||||
path = self._state.tab.get_current_directory()
|
||||
parts = uri.split("/")
|
||||
uri = self._state.selected_files[0]
|
||||
path = self._state.tab.get_current_directory()
|
||||
parts = uri.split("/")
|
||||
|
||||
file_hash = hashlib.sha256(str.encode(uri)).hexdigest()
|
||||
hash_img_pth = f"{self._state.tab.ABS_THUMBS_PTH}/{file_hash}.jpg"
|
||||
img_pixbuf = GdkPixbuf.Pixbuf.new_from_file(hash_img_pth)
|
||||
file_hash = hashlib.sha256(str.encode(uri)).hexdigest()
|
||||
hash_img_pth = f"{self._state.tab.ABS_THUMBS_PTH}/{file_hash}.jpg"
|
||||
preview_pixbuf = GdkPixbuf.Pixbuf.new_from_file(hash_img_pth)
|
||||
|
||||
self._thumbnail_preview_img.set_from_pixbuf(img_pixbuf)
|
||||
self._thumbnail_preview_img.set_from_pixbuf(preview_pixbuf)
|
||||
self._file_name.set_text(parts[ len(parts) - 1 ])
|
||||
self._file_location.set_text(path)
|
||||
self._file_hash.set_text(file_hash)
|
||||
|
Reference in New Issue
Block a user