merged recursive loader operator into main operator file
authorCarlos Padial <palidoestudio2@gmail.com>
Wed, 2 Jan 2013 13:06:47 +0000 (13:06 +0000)
committerCarlos Padial <palidoestudio2@gmail.com>
Wed, 2 Jan 2013 13:06:47 +0000 (13:06 +0000)
removed operator_recursive.py file
fixed blender version

sequencer_extra_actions/__init__.py
sequencer_extra_actions/functions.py
sequencer_extra_actions/operators_extra_actions.py
sequencer_extra_actions/operators_recursive.py [deleted file]

index 7cf0b1491242fd0be81b88f1aca14d3b11e6fc29..5443ff6e4f3b46f575337b40bd2f6eae92f22942 100644 (file)
@@ -19,9 +19,9 @@
 bl_info = {
     "name": "Extra Sequencer Actions",
     "author": "Turi Scandurra, Carlos Padial",
-    "version": (3, 5),
-    "blender": (2, 63, 0),
-    "api": 49500,
+    "version": (3, 6),
+    "blender": (2, 65, 0),
+    "api": 53177,
     "category": "Sequencer",
     "location": "Sequencer",
     "description": "Collection of extra operators to manipulate VSE strips",
@@ -35,11 +35,11 @@ if "bpy" in locals():
     import imp
     imp.reload(operators_extra_actions)
     imp.reload(ui)
-    imp.reload(operators_recursive)
+    #imp.reload(operators_recursive)
 else:
     from . import operators_extra_actions
     from . import ui
-    from . import operators_recursive
+    #from . import operators_recursive
 
 import bpy
 import os.path
index c3c315bb271992ad8f0727390a878014b76bbfe3..c603dd1df99790fa9ded075471cf719a5e1fed59 100644 (file)
@@ -41,6 +41,31 @@ imb_ext_movie = [
     ".m2t", ".m2ts", ".mts", ".mv", ".avs", ".wmv", ".ogv",
     ".dv", ".mpeg", ".mpg", ".mpg2", ".vob", ".mkv", ".flv",
     ".divx", ".xvid", ".mxf"]
+    
+movieextdict = [("1", ".avi", ""),
+            ("2", ".flc", ""),
+            ("3", ".mov", ""),
+            ("4", ".movie", ""),
+            ("5", ".mp4", ""),
+            ("6", ".m4v", ""),
+            ("7", ".m2v", ""),
+            ("8", ".m2t", ""),
+            ("9", ".m2ts", ""),
+            ("10", ".mts", ""),
+            ("11", ".mv", ""),
+            ("12", ".avs", ""),
+            ("13", ".wmv", ""),
+            ("14", ".ogv", ""),
+            ("15", ".dv", ""),
+            ("16", ".mpeg", ""),
+            ("17", ".mpg", ""),
+            ("18", ".mpg2", ""),
+            ("19", ".vob", ""),
+            ("20", ".mkv", ""),
+            ("21", ".flv", ""),
+            ("22", ".divx", ""),
+            ("23", ".xvid", ""),
+            ("24", ".mxf", "")]
 
 
 # Functions
@@ -70,7 +95,7 @@ def detect_strip_type(filepath):
 
     imb_ext_movie = [
     ".avi", ".flc", ".mov", ".movie", ".mp4", ".m4v", ".m2v",
-    ".m2t", ".m2ts", ".mts", ".mv", ".avs", ".wmv", ".ogv",
+    ".m2t", ".m2ts", ".mts", ".mv", ".avs", ".wmv", ".ogv", ".ogg",
     ".dv", ".mpeg", ".mpg", ".mpg2", ".vob", ".mkv", ".flv",
     ".divx", ".xvid", ".mxf"]
 
@@ -163,6 +188,73 @@ def sortlist(filelist):
     '''
     filelist_sorted = sorted(filelist, key=operator.itemgetter(1))
     return filelist_sorted
+    
+# recursive load functions 
+
+def loader(filelist):
+    scn = bpy.context.scene
+    if filelist:
+        for i in filelist:
+            setpathinbrowser(i[0], i[1])
+            try:
+                if scn.default_recursive_proxies:
+                    bpy.ops.sequencerextra.placefromfilebrowserproxy(
+                        proxy_suffix=scn.default_proxy_suffix,
+                        proxy_extension=scn.default_proxy_extension,
+                        proxy_path=scn.default_proxy_path,
+                        build_25=scn.default_build_25,
+                        build_50=scn.default_build_50,
+                        build_75=scn.default_build_75,
+                        build_100=scn.default_build_100)
+                else:
+                    bpy.ops.sequencerextra.placefromfilebrowser()
+            except:
+                print("Error loading file (recursive loader error): ", i[1])
+                add_marker(i[1])
+                #self.report({'ERROR_INVALID_INPUT'}, 'Error loading file ')
+                #return {'CANCELLED'}
+                pass
+
+def onefolder():
+    '''
+    returns a list of MOVIE type files from folder selected in file browser
+    '''
+    filelist = []
+    path, filename = getfilepathfrombrowser()
+    extension = filename.rpartition(".")[2]
+    #extension = scn.default_ext
+    scn = bpy.context.scene
+
+    if detect_strip_type(path + filename) == 'MOVIE':
+        if scn.default_recursive_ext == True:
+            for file in os.listdir(path):
+                if file.rpartition(".")[2] == extension:
+                    filelist.append((path, file))
+        else:
+            for file in os.listdir(path):
+                filelist.append((path, file))
+    return (filelist)
+
+def recursive():
+    '''
+    returns a list of MOVIE type files recursively from file browser
+    '''
+    filelist = []
+    path = getpathfrombrowser()
+    scn = bpy.context.scene
+    for i in movieextlist:
+        if i[0] == scn.default_ext:
+            extension = i[1].rpartition(".")[2]
+    #pythonic way to magic:
+    for root, dirs, files in os.walk(path):
+        for f in files:
+            if scn.default_recursive_ext == True:
+                if f.rpartition(".")[2] == extension:
+                    filelist.append((root, f))
+            else:
+                filelist.append((root, f))
+    return filelist   
+
 
 
 # jump to cut functions
@@ -182,3 +274,28 @@ def triminout(strip, sin, sout):
             bpy.ops.sequencer.snap(frame=sout)
             strip.select_right_handle = False
     return {'FINISHED'}
+
+
+#------------ random edit functions...
+
+def randompartition(lst,n,rand):
+    division = len(lst) / float(n)
+    lista = []
+    for i in range(n): lista.append(division)
+    var=0
+    for i in range(n-1):
+        lista[i]+= random.randint(-int(rand*division),int(rand*division))
+        var+=lista[i]
+    if lista[n-1] != len(lst)-var:
+        lista[n-1] = len(lst)-var
+    random.shuffle(lista)
+    division = len(lst) / float(n)
+    count = 0
+    newlist=[]
+    for i in range(n):
+        print(lst[count : int(lista[i]-1)+count])
+        newlist.append([lst[count : int(lista[i]-1)+count]])
+        count += int(lista[i]) 
+    return newlist
+
+
index 374a1fcc6cc8db621c041096b465ae39574ff1c5..57f17ec0abf788405640caaeb039a3d69dc1e8c9 100644 (file)
@@ -22,19 +22,18 @@ align strip to the left (shift-s + -lenght)
 
 '''
 
+import bpy
+
 import random
 import math
+import os, sys
 
-
-import bpy
-import os.path
 from bpy.props import IntProperty
 from bpy.props import FloatProperty
 from bpy.props import EnumProperty
 from bpy.props import BoolProperty
 from bpy.props import StringProperty
 
-from . import functions
 from . import functions
 from . import exiftool
 
@@ -48,17 +47,17 @@ def initSceneProperties(scn):
         pass
 
     bpy.types.Scene.default_slide_offset = IntProperty(
-    name='Offset',
-    description='Number of frames to slide',
-    min=-250, max=250,
-    default=0)
+        name='Offset',
+        description='Number of frames to slide',
+        min=-250, max=250,
+        default=0)
     scn.default_slide_offset = 0
 
     bpy.types.Scene.default_fade_duration = IntProperty(
-    name='Duration',
-    description='Number of frames to fade',
-    min=1, max=250,
-    default=scn.render.fps)
+        name='Duration',
+        description='Number of frames to fade',
+        min=1, max=250,
+        default=scn.render.fps)
     scn.default_fade_duration = scn.render.fps
 
     bpy.types.Scene.default_fade_amount = FloatProperty(
@@ -124,11 +123,37 @@ def initSceneProperties(scn):
         description='default build_100',
         default=False)
     scn.default_build_100 = False
+    
+    bpy.types.Scene.default_recursive = BoolProperty(
+        name='Recursive',
+        description='Load in recursive folders',
+        default=False)
+    scn.default_recursive = False
+
+    bpy.types.Scene.default_recursive_ext = BoolProperty(
+        name='Recursive ext',
+        description='Load only clips with selected extension',
+        default=False)
+    scn.default_recursive_ext = False
+
+    bpy.types.Scene.default_recursive_proxies = BoolProperty(
+        name='Recursive proxies',
+        description='Load in recursive folders + proxies',
+        default=False)
+    scn.default_recursive_proxies = False
+    
+    bpy.types.Scene.default_ext = EnumProperty(
+        items=functions.movieextdict,
+        name="ext enum",
+        default="3")
+    scn.default_ext = "3"
 
     bpy.types.Scene.scene_initialized = BoolProperty(
         name='Init',
         default=False)
     scn.scene_initialized = True
+    
+    
 
     return True
 
@@ -1650,6 +1675,22 @@ class Sequencer_Extra_CreateMovieclip(bpy.types.Operator):
                     a.spaces[0].clip = data
 
         return {'FINISHED'}
+        
+        
+# RECURSIVE LOADER
+
+class Sequencer_Extra_RecursiveLoader(bpy.types.Operator):
+    bl_idname = "sequencerextra.recursiveload"
+    bl_label = "recursive load"
+    bl_options = {'REGISTER', 'UNDO'}
+
+    def execute(self, context):
+        scn = bpy.context.scene
+        if scn["default_recursive"] == True:
+            functions.loader(functions.sortlist(functions.recursive()))
+        else:
+            functions.loader(functions.sortlist(functions.onefolder()))
+        return {'FINISHED'}
 
 
 # READ EXIF DATA
diff --git a/sequencer_extra_actions/operators_recursive.py b/sequencer_extra_actions/operators_recursive.py
deleted file mode 100644 (file)
index 44498e2..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-#  This program is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-"""
-TODO: Add 'scene creation for each clip' option
-
-"""
-
-import bpy
-import os
-import sys
-from bpy.props import BoolProperty
-from bpy.props import EnumProperty
-from . import functions
-
-scn = bpy.context.scene
-
-bpy.types.Scene.default_recursive = BoolProperty(
-name='Recursive',
-description='Load in recursive folders',
-default=False)
-scn.default_recursive = False
-
-bpy.types.Scene.default_recursive_ext = BoolProperty(
-name='Recursive ext',
-description='Load only clips with selected extension',
-default=False)
-scn.default_recursive_ext = False
-
-bpy.types.Scene.default_recursive_proxies = BoolProperty(
-name='Recursive proxies',
-description='Load in recursive folders + proxies',
-default=False)
-scn.default_recursive_proxies = False
-
-movieextlist = [("1", ".avi", ""),
-            ("2", ".flc", ""),
-            ("3", ".mov", ""),
-            ("4", ".movie", ""),
-            ("5", ".mp4", ""),
-            ("6", ".m4v", ""),
-            ("7", ".m2v", ""),
-            ("8", ".m2t", ""),
-            ("9", ".m2ts", ""),
-            ("10", ".mts", ""),
-            ("11", ".mv", ""),
-            ("12", ".avs", ""),
-            ("13", ".wmv", ""),
-            ("14", ".ogv", ""),
-            ("15", ".dv", ""),
-            ("16", ".mpeg", ""),
-            ("17", ".mpg", ""),
-            ("18", ".mpg2", ""),
-            ("19", ".vob", ""),
-            ("20", ".mkv", ""),
-            ("21", ".flv", ""),
-            ("22", ".divx", ""),
-            ("23", ".xvid", ""),
-            ("24", ".mxf", "")]
-
-bpy.types.Scene.default_ext = EnumProperty(
-items=movieextlist,
-name="ext enum",
-default="3")
-scn.default_ext = "3"
-
-
-def loader(filelist):
-    if filelist:
-        for i in filelist:
-            functions.setpathinbrowser(i[0], i[1])
-            try:
-                if scn.default_recursive_proxies:
-                    bpy.ops.sequencerextra.placefromfilebrowserproxy(
-                        proxy_suffix=scn.default_proxy_suffix,
-                        proxy_extension=scn.default_proxy_extension,
-                        proxy_path=scn.default_proxy_path,
-                        build_25=scn.default_build_25,
-                        build_50=scn.default_build_50,
-                        build_75=scn.default_build_75,
-                        build_100=scn.default_build_100)
-                else:
-                    bpy.ops.sequencerextra.placefromfilebrowser()
-            except:
-                print("Error loading file (recursive loader error): ", i[1])
-                functions.add_marker(i[1])
-                #self.report({'ERROR_INVALID_INPUT'}, 'Error loading file ')
-                #return {'CANCELLED'}
-                pass
-
-
-def onefolder():
-    '''
-    returns a list of MOVIE type files from folder selected in file browser
-    '''
-    filelist = []
-    path, filename = functions.getfilepathfrombrowser()
-    extension = filename.rpartition(".")[2]
-    #extension = scn.default_ext
-    scn = bpy.context.scene
-
-    if functions.detect_strip_type(path + filename) == 'MOVIE':
-        if scn.default_recursive_ext == True:
-            for file in os.listdir(path):
-                if file.rpartition(".")[2] == extension:
-                    filelist.append((path, file))
-        else:
-            for file in os.listdir(path):
-                filelist.append((path, file))
-    return (filelist)
-    #loader(sortlist(filelist))
-
-
-def recursive():
-    '''
-    returns a list of MOVIE type files recursively from file browser
-    '''
-    filelist = []
-    path = functions.getpathfrombrowser()
-    scn = bpy.context.scene
-    for i in movieextlist:
-        if i[0] == scn.default_ext:
-            extension = i[1].rpartition(".")[2]
-    #pythonic way to magic:
-    for root, dirs, files in os.walk(path):
-        for f in files:
-            if scn.default_recursive_ext == True:
-                if f.rpartition(".")[2] == extension:
-                    filelist.append((root, f))
-            else:
-                filelist.append((root, f))
-    return filelist
-    #loader(sortlist(filelist))
-
-
-class Sequencer_Extra_RecursiveLoader(bpy.types.Operator):
-    bl_idname = "sequencerextra.recursiveload"
-    bl_label = "recursive load"
-    bl_options = {'REGISTER', 'UNDO'}
-
-    def execute(self, context):
-        scn = bpy.context.scene
-        if scn["default_recursive"] == True:
-            loader(functions.sortlist(recursive()))
-        else:
-            loader(functions.sortlist(onefolder()))
-        return {'FINISHED'}