Skip to content

Commit

Permalink
try to make date an int with seconds since epoch
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.freevo.org/kaa/trunk/metadata@2800 a8f5125c-1e01-0410-8897-facf34644b8e
  • Loading branch information
Dirk Meyer committed Sep 7, 2007
1 parent 937a1e9 commit e546bcb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
12 changes: 12 additions & 0 deletions README
Expand Up @@ -8,3 +8,15 @@ optional: libdvdread for DVD support


License: GPL


Known Bugs:

Date should be returned as int in seconds since the epoch. This should
be the case for jpg, avi, mp4 and mkv. The mp3 parser returns the date
as it was set in the ID3 field. Since there is no real standard, this
can be everything from the year to a complex string. The current
possible values for ogg and flac are untested, other parser have no
date field. But checking date for int should mean that the value is
seconds since epoch.

2 changes: 0 additions & 2 deletions TODO
Expand Up @@ -18,8 +18,6 @@ Add list of external files kaa.beacon should know about

Check attributes. Some are very similar and could be merged

Make data int

Make bitrate kbit/s

If possible, attributes should match
Expand Down
8 changes: 7 additions & 1 deletion src/image/jpg.py
Expand Up @@ -33,6 +33,7 @@

# python imports
import struct
import time
import logging
import cStringIO

Expand Down Expand Up @@ -64,7 +65,6 @@
}

EXIFMap = {
'Image DateTime': 'date',
'Image Artist': 'artist',
'Image Model': 'hardware',
'Image Software': 'software',
Expand Down Expand Up @@ -130,6 +130,12 @@ def __init__(self,file):
self.rotation = 270
elif orientation.find('180') > 0:
self.rotation = 180
date = exif.get('Image DateTimeOriginal')
if not date:
date = exif.get('Image DateTime')
if date:
t = time.strptime(str(date), '%Y:%m:%d %H:%M:%S')
self.date = int(time.mktime(t))
elif type == 'http://ns.adobe.com/xap/1.0/':
# FIXME: parse XMP data (xml)
doc = data[data.find('\0')+1:]
Expand Down
2 changes: 1 addition & 1 deletion src/video/mkv.py
Expand Up @@ -343,7 +343,7 @@ def process_elem(self, elem):
elif ielem_id == MATROSKA_DATE_UTC_ID:
self.date = unpack('!q', ielem.get_data())[0] / 10.0**9
# Date is offset 2001-01-01 00:00:00 (timestamp 978307200.0)
self.date += 978307200.0
self.date = int(self.date + 978307200)

self.length = duration * scalecode / 1000000000.0

Expand Down
4 changes: 1 addition & 3 deletions src/video/mp4.py
Expand Up @@ -171,10 +171,8 @@ def _readatom(self, file):
try:
# XXX Date number of Seconds is since January 1st 1904!
# XXX 2082844800 is the difference between Unix and
# XXX Apple time. Fix me to work on Apple, too
# XXX Apple time. FIXME to work on Apple, too
self.date = int(tkhd[1]) - 2082844800
self.date = time.strftime('%y.%m.%d %H:%M:%S',
time.gmtime(self.date))
except Exception, e:
log.exception('There was trouble extracting the date')

Expand Down
6 changes: 2 additions & 4 deletions src/video/riff.py
Expand Up @@ -477,10 +477,8 @@ def _parseLIST(self,t):
log.debug('no support for time format %s', value)
date = 0
if date:
# format date to something similar to a date in an
# EXIF header. This creates one unique way in
# kaa.metadata to handle this.
self.date = time.strftime("%Y:%m:%d %H:%M:%S", date)
# save date as int
self.date = int(time.mktime(date))
i+=sz
return retval

Expand Down

0 comments on commit e546bcb

Please sign in to comment.