]> git.parisson.com Git - telemeta.git/commitdiff
fix bad SQL query with postgresl
authoryomguy <yomguy@parisson.com>
Fri, 8 Feb 2013 00:53:08 +0000 (01:53 +0100)
committeryomguy <yomguy@parisson.com>
Fri, 8 Feb 2013 00:53:08 +0000 (01:53 +0100)
add relative marker offset to the kdenlive parsing

telemeta/models/query.py
telemeta/util/kdenlive/session.py

index df6d17787e95a7933804e3148c8e31f9acdbf12b..c5f1d991084811c11d11baab1bc14062c2c3da22 100644 (file)
@@ -157,7 +157,7 @@ class MediaItemQuerySet(CoreQuerySet):
         from telemeta.models import Location
         for f in args:
             if f == 'apparent_collector':
-                if not 'sqlite3' in engine:
+                if not 'sqlite3' in engine and not 'postgresql_psycopg2':
                     related.append('collection')
                     qs = qs.extra(select={f:
                         'IF(collector_from_collection, '
@@ -167,7 +167,7 @@ class MediaItemQuerySet(CoreQuerySet):
                             'media_items.collector)'})
             elif f == 'country_or_continent':
                 related.append('location')
-                if not 'sqlite3' in engine:
+                if not 'sqlite3' in engine and not 'postgresql_psycopg2':
                     qs = qs.extra(select={f:
                         'IF(locations.type = ' + str(Location.COUNTRY) + ' '
                         'OR locations.type = ' + str(Location.CONTINENT) + ','
index f76f9d1ed3e26ac699dea7ab3384e4b48ccedc24..32fca7d42331184471f719fb8ae2273894293a36 100644 (file)
@@ -109,28 +109,45 @@ class KDEnLiveSession(object):
                except:
                        return text
 
-       def markers_relative(self, offset=0):
+       def markers_relative(self, offset=0, from_first_marker=False):
+               """ by default return a dict of markers with timecodes relative to an origin
+
+                   if from_first_marker=False: the origin is the first entry timecode
+                   if from_first_marker=True: the origin is the first entry timecode before the first marker
+
+                   offset: general origin offset
+               """
+
+               abs_time = 0
                markers = []
+               i = 0
                entries = self.entries_video_seconds()
+
                for attr in self.session['children']:
                        if 'kdenlivedoc' in attr['name']:
+
                                for att in attr['children']:
                                        if 'markers' in att['name'] and 'children' in att.keys():
+
                                                for at in att['children']:
                                                        if 'marker' in at['name']:
-                                                               rel_time = float(at['attributes']['time'].replace(',','.'))
+
+                                                               marker_time = float(at['attributes']['time'].replace(',','.'))
                                                                id = at['attributes']['id']
-                                                               abs_time = 0
+                                                               rel_time = 0
 
                                                                for entry in entries:
-                                                                       if rel_time > entry['in'] and rel_time < entry['out'] and id == entry['id']:
-                                                                               abs_time = entry['t'] + (rel_time - entry['in'])
+                                                                       if marker_time >= entry['in'] and marker_time <= entry['out'] and id == entry['id']:
+                                                                               if i == 0 and from_first_marker:
+                                                                                       abs_time = entry['t']
+                                                                               rel_time = entry['t'] + (marker_time - entry['in']) - abs_time + offset
                                                                                break
 
-                                                               at['attributes']['time'] = abs_time
-                                                               at['attributes']['session_timecode'] = time.strftime('%H:%M:%S', time.gmtime(abs_time+offset))
+                                                               at['attributes']['time'] = rel_time
+                                                               at['attributes']['session_timecode'] = time.strftime('%H:%M:%S', time.gmtime(rel_time))
                                                                at['attributes']['comment'] = self.fix_text(at['attributes']['comment'])
                                                                markers.append(at['attributes'])
 
+                                                       i += 1
                return markers