added file argument to video resizer and added ascii resizer
authorRodney Ewing <ewing.rj@gmail.com>
Wed, 14 Aug 2013 00:42:42 +0000 (17:42 -0700)
committerRodney Ewing <ewing.rj@gmail.com>
Fri, 16 Aug 2013 22:30:20 +0000 (15:30 -0700)
mediagoblin/media_types/ascii/processing.py
mediagoblin/media_types/video/processing.py

index 4cf8081a9fd96126f4120a06447cca26d39e08f5..82ee9cd746af029e21a05398410e6bb351189aa2 100644 (file)
@@ -189,6 +189,52 @@ class InitialProcessor(CommonAsciiProcessor):
         self.delete_queue_file()
 
 
+class Resizer(CommonAsciiProcessor):
+    """
+    Resizing process steps for processed media
+    """
+    name = 'resize'
+    description = 'Resize thumbnail'
+
+    @classmethod
+    def media_is_eligible(cls, entry=None, state=None):
+        """
+        Determine if this media type is eligible for processing
+        """
+        if not state:
+            state = entry.state
+        return state in 'processed'
+
+    @classmethod
+    def generate_parser(cls):
+        parser = argparse.ArgumentParser(
+            description=cls.description,
+            prog=cls.name)
+
+        parser.add_argument(
+            '--thumb_size',
+            nargs=2,
+            metavar=('max_width', 'max_height'),
+            type=int)
+
+        # Needed for gmg reprocess thumbs to work
+        parser.add_argument(
+            'file',
+            nargs='?',
+            default='thumb')
+
+        return parser
+
+    @classmethod
+    def args_to_request(cls, args):
+        return request_from_args(
+            args, ['size', 'file'])
+
+    def process(self, thumb_size=None, file=None):
+        self.common_setup()
+        self.generate_thumb(thumb_size=thumb_size)
+
+
 class AsciiProcessingManager(ProcessingManager):
     def __init__(self):
         super(self.__class__, self).__init__()
index 3f96dc6632f4cb11fda6efeb02d2afe34b12b3e0..ab78e8edaaf72537118de815301ab2ec61ac4a03 100644 (file)
@@ -309,14 +309,20 @@ class Resizer(CommonVideoProcessor):
             metavar=('max_width', 'max_height'),
             type=int)
 
+        # Needed for gmg reprocess thumbs to work
+        parser.add_argument(
+            'file',
+            nargs='?',
+            default='thumb')
+
         return parser
 
     @classmethod
     def args_to_request(cls, args):
         return request_from_args(
-            args, ['thumb_size'])
+            args, ['thumb_size', 'file'])
 
-    def process(self, thumb_size=None):
+    def process(self, thumb_size=None, file=None):
         self.common_setup()
         self.generate_thumb(thumb_size=thumb_size)