[pitivi] proxy: add_job restucture



commit 64412a2591701812edae1641a96ba999fc47132e
Author: Ritwik Puri <ritwikpuri5678 gmail com>
Date:   Sun Apr 12 14:54:03 2020 +0530

    proxy: add_job restucture
    
    Took some re-occuring code out of
    
            if video_streams:..
            else:...

 pitivi/utils/proxy.py | 44 ++++++++++++++------------------------------
 1 file changed, 14 insertions(+), 30 deletions(-)
---
diff --git a/pitivi/utils/proxy.py b/pitivi/utils/proxy.py
index 09af86e7..bedf006c 100644
--- a/pitivi/utils/proxy.py
+++ b/pitivi/utils/proxy.py
@@ -751,39 +751,23 @@ class ProxyManager(GObject.Object, Loggable):
                 hq_uri = self.app.proxy_manager.get_proxy_uri(asset)
                 if not Gio.File.new_for_uri(hq_uri).query_exists(None):
                     self.add_job(asset, shadow=True)
-
-            if scaled:
-                if self.is_asset_queued(asset, optimisation=False):
-                    self.log("Asset already queued for scaling: %s", asset)
-                    return
-            else:
-                if self.is_asset_queued(asset, scaling=False):
-                    self.log("Asset already queued for optimization: %s", asset)
-                    return
-
-            if not force_proxying:
-                if not self.__asset_needs_transcoding(asset, scaled):
-                    self.debug("Not proxying asset (proxying disabled: %s)",
-                               self.proxying_unsupported)
-                    # Make sure to notify we do not need a proxy for that asset.
-                    self.emit("proxy-ready", asset, None)
-                    return
-
-            self.__create_transcoder(asset, scaled=scaled, shadow=shadow)
         else:
-            if self.is_asset_queued(asset, scaling=False):
-                self.log("Asset already queued for optimization: %s", asset)
-                return
+            # Scaled proxy is not for audio assets
+            scaled = False
 
-            if not force_proxying:
-                if not self.__asset_needs_transcoding(asset, scaled):
-                    self.debug("Not proxying asset (proxying disabled: %s)",
-                               self.proxying_unsupported)
-                    # Make sure to notify we do not need a proxy for that asset.
-                    self.emit("proxy-ready", asset, None)
-                    return
+        if self.is_asset_queued(asset, scaling=scaled, optimisation=not scaled):
+            self.log("Asset %s already queued for %s", asset, "scaling" if scaled else "optimization")
+            return
+
+        if not force_proxying:
+            if not self.__asset_needs_transcoding(asset, scaled):
+                self.debug("Not proxying asset (proxying disabled: %s)",
+                           self.proxying_unsupported)
+                # Make sure to notify we do not need a proxy for that asset.
+                self.emit("proxy-ready", asset, None)
+                return
 
-            self.__create_transcoder(asset)
+        self.__create_transcoder(asset, scaled=scaled, shadow=shadow)
 
 
 def get_proxy_target(obj):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]