Subliminal update
This commit is contained in:
1 parent
5321037f08
commit
148e1940ac
85 files changed
+4375
-3420
No files matched your search
+33
-34
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# enzyme - Video metadata parser
|
||||
# Copyright (C) 2011 Antoine Bertin <diaoulael@gmail.com>
|
||||
# Copyright (C) 2003-2006 Thomas Schueppel <stain@acm.org>
|
||||
# Copyright (C) 2003-2006 Dirk Meyer <dischi@freevo.org>
|
||||
# Copyright (C) 2003-2006 Jason Tackaberry <tack@urandom.ca>
|
||||
# Copyright 2011-2012 Antoine Bertin <diaoulael@gmail.com>
|
||||
# Copyright 2003-2006 Thomas Schueppel <stain@acm.org>
|
||||
# Copyright 2003-2006 Dirk Meyer <dischi@freevo.org>
|
||||
# Copyright 2003-2006 Jason Tackaberry <tack@urandom.ca>
|
||||
#
|
||||
# This file is part of enzyme.
|
||||
#
|
||||
@@ -18,18 +18,17 @@
|
||||
# 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
__all__ = ['Parser']
|
||||
|
||||
# along with enzyme. If not, see <http://www.gnu.org/licenses/>.
|
||||
from datetime import datetime
|
||||
from exceptions import *
|
||||
from exceptions import ParseError
|
||||
from struct import unpack
|
||||
import core
|
||||
import logging
|
||||
import re
|
||||
|
||||
__all__ = ['Parser']
|
||||
|
||||
|
||||
# get logging object
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -236,7 +235,7 @@ class EbmlEntity:
|
||||
self.compute_id(inbuf)
|
||||
|
||||
if self.id_len == 0:
|
||||
log.error("EBML entity not found, bad file format")
|
||||
log.error(u'EBML entity not found, bad file format')
|
||||
raise ParseError()
|
||||
|
||||
self.entity_len, self.len_size = self.compute_len(inbuf[self.id_len:])
|
||||
@@ -247,7 +246,7 @@ class EbmlEntity:
|
||||
# if the data size is 8 or less, it could be a numeric value
|
||||
self.value = 0
|
||||
if self.entity_len <= 8:
|
||||
for pos, shift in zip(range(self.entity_len), range((self.entity_len-1)*8, -1, -8)):
|
||||
for pos, shift in zip(range(self.entity_len), range((self.entity_len - 1) * 8, -1, -8)):
|
||||
self.value |= ord(self.entity_data[pos]) << shift
|
||||
|
||||
|
||||
@@ -271,19 +270,19 @@ class EbmlEntity:
|
||||
if len(inbuf) < 2:
|
||||
return 0
|
||||
self.id_len = 2
|
||||
self.entity_id = ord(inbuf[0])<<8 | ord(inbuf[1])
|
||||
self.entity_id = ord(inbuf[0]) << 8 | ord(inbuf[1])
|
||||
elif first & 0x20:
|
||||
if len(inbuf) < 3:
|
||||
return 0
|
||||
self.id_len = 3
|
||||
self.entity_id = (ord(inbuf[0])<<16) | (ord(inbuf[1])<<8) | \
|
||||
self.entity_id = (ord(inbuf[0]) << 16) | (ord(inbuf[1]) << 8) | \
|
||||
(ord(inbuf[2]))
|
||||
elif first & 0x10:
|
||||
if len(inbuf) < 4:
|
||||
return 0
|
||||
self.id_len = 4
|
||||
self.entity_id = (ord(inbuf[0])<<24) | (ord(inbuf[1])<<16) | \
|
||||
(ord(inbuf[2])<<8) | (ord(inbuf[3]))
|
||||
self.entity_id = (ord(inbuf[0]) << 24) | (ord(inbuf[1]) << 16) | \
|
||||
(ord(inbuf[2]) << 8) | (ord(inbuf[3]))
|
||||
self.entity_str = inbuf[0:self.id_len]
|
||||
|
||||
|
||||
@@ -381,7 +380,7 @@ class Matroska(core.AVContainer):
|
||||
if header.get_id() != MATROSKA_HEADER_ID:
|
||||
raise ParseError()
|
||||
|
||||
log.debug("HEADER ID found %08X" % header.get_id() )
|
||||
log.debug(u'HEADER ID found %08X' % header.get_id())
|
||||
self.mime = 'video/x-matroska'
|
||||
self.type = 'Matroska'
|
||||
self.has_idx = False
|
||||
@@ -392,10 +391,10 @@ class Matroska(core.AVContainer):
|
||||
# Record file offset of segment data for seekheads
|
||||
self.segment.offset = header.get_total_len() + segment.get_header_len()
|
||||
if segment.get_id() != MATROSKA_SEGMENT_ID:
|
||||
log.debug("SEGMENT ID not found %08X" % segment.get_id())
|
||||
log.debug(u'SEGMENT ID not found %08X' % segment.get_id())
|
||||
return
|
||||
|
||||
log.debug("SEGMENT ID found %08X" % segment.get_id())
|
||||
log.debug(u'SEGMENT ID found %08X' % segment.get_id())
|
||||
try:
|
||||
for elem in self.process_one_level(segment):
|
||||
if elem.get_id() == MATROSKA_SEEKHEAD_ID:
|
||||
@@ -404,12 +403,12 @@ class Matroska(core.AVContainer):
|
||||
pass
|
||||
|
||||
if not self.has_idx:
|
||||
log.warning('File has no index')
|
||||
log.warning(u'File has no index')
|
||||
self._set('corrupt', True)
|
||||
|
||||
def process_elem(self, elem):
|
||||
elem_id = elem.get_id()
|
||||
log.debug('BEGIN: process element %s' % hex(elem_id))
|
||||
log.debug(u'BEGIN: process element %r' % hex(elem_id))
|
||||
if elem_id == MATROSKA_SEGMENT_INFO_ID:
|
||||
duration = 0
|
||||
scalecode = 1000000.0
|
||||
@@ -423,7 +422,7 @@ class Matroska(core.AVContainer):
|
||||
elif ielem_id == MATROSKA_TITLE_ID:
|
||||
self.title = ielem.get_utf8()
|
||||
elif ielem_id == MATROSKA_DATE_UTC_ID:
|
||||
timestamp = unpack('!q', ielem.get_data())[0] / 10.0**9
|
||||
timestamp = unpack('!q', ielem.get_data())[0] / 10.0 ** 9
|
||||
# Date is offset 2001-01-01 00:00:00 (timestamp 978307200.0)
|
||||
self.timestamp = int(timestamp + 978307200)
|
||||
|
||||
@@ -447,7 +446,7 @@ class Matroska(core.AVContainer):
|
||||
elif elem_id == MATROSKA_CUES_ID:
|
||||
self.has_idx = True
|
||||
|
||||
log.debug('END: process element %s' % hex(elem_id))
|
||||
log.debug(u'END: process element %r' % hex(elem_id))
|
||||
return True
|
||||
|
||||
|
||||
@@ -479,7 +478,7 @@ class Matroska(core.AVContainer):
|
||||
index = 0
|
||||
while index < tracks.get_len():
|
||||
trackelem = EbmlEntity(tracksbuf[index:])
|
||||
log.debug ("ELEMENT %X found" % trackelem.get_id())
|
||||
log.debug (u'ELEMENT %X found' % trackelem.get_id())
|
||||
self.process_track(trackelem)
|
||||
index += trackelem.get_total_len() + trackelem.get_crc_len()
|
||||
|
||||
@@ -503,20 +502,20 @@ class Matroska(core.AVContainer):
|
||||
elements = [x for x in self.process_one_level(track)]
|
||||
track_type = [x.get_value() for x in elements if x.get_id() == MATROSKA_TRACK_TYPE_ID]
|
||||
if not track_type:
|
||||
log.debug('Bad track: no type id found')
|
||||
log.debug(u'Bad track: no type id found')
|
||||
return
|
||||
|
||||
track_type = track_type[0]
|
||||
track = None
|
||||
|
||||
if track_type == MATROSKA_VIDEO_TRACK:
|
||||
log.debug("Video track found")
|
||||
log.debug(u'Video track found')
|
||||
track = self.process_video_track(elements)
|
||||
elif track_type == MATROSKA_AUDIO_TRACK:
|
||||
log.debug("Audio track found")
|
||||
log.debug(u'Audio track found')
|
||||
track = self.process_audio_track(elements)
|
||||
elif track_type == MATROSKA_SUBTITLES_TRACK:
|
||||
log.debug("Subtitle track found")
|
||||
log.debug(u'Subtitle track found')
|
||||
track = core.Subtitle()
|
||||
self.set_track_defaults(track)
|
||||
track.id = len(self.subtitles)
|
||||
@@ -529,7 +528,7 @@ class Matroska(core.AVContainer):
|
||||
elem_id = elem.get_id()
|
||||
if elem_id == MATROSKA_TRACK_LANGUAGE_ID:
|
||||
track.language = elem.get_str()
|
||||
log.debug("Track language found: %s" % track.language)
|
||||
log.debug(u'Track language found: %r' % track.language)
|
||||
elif elem_id == MATROSKA_NAME_ID:
|
||||
track.title = elem.get_utf8()
|
||||
elif elem_id == MATROSKA_TRACK_NUMBER_ID:
|
||||
@@ -671,7 +670,7 @@ class Matroska(core.AVContainer):
|
||||
elif elem_id == MATROSKA_CHAPTER_UID_ID:
|
||||
self.objects_by_uid[elem.get_value()] = chap
|
||||
|
||||
log.debug('Chapter "%s" found', chap.name)
|
||||
log.debug(u'Chapter %r found', chap.name)
|
||||
chap.id = len(self.chapters)
|
||||
self.chapters.append(chap)
|
||||
|
||||
@@ -704,10 +703,10 @@ class Matroska(core.AVContainer):
|
||||
|
||||
# Right now we only support attachments that could be cover images.
|
||||
# Make a guess to see if this attachment is a cover image.
|
||||
if mimetype.startswith("image/") and u"cover" in (name+desc).lower() and data:
|
||||
if mimetype.startswith("image/") and u"cover" in (name + desc).lower() and data:
|
||||
self.thumbnail = data
|
||||
|
||||
log.debug('Attachment "%s" found' % name)
|
||||
log.debug(u'Attachment %r found' % name)
|
||||
|
||||
|
||||
def process_tags(self, tags):
|
||||
@@ -744,7 +743,7 @@ class Matroska(core.AVContainer):
|
||||
self.objects_by_uid[target].tags.update(tags_dict)
|
||||
self.tags_to_attributes(self.objects_by_uid[target], tags_dict)
|
||||
except KeyError:
|
||||
log.warning('Tags assigned to unknown/unsupported target uid %d', target)
|
||||
log.warning(u'Tags assigned to unknown/unsupported target uid %d', target)
|
||||
else:
|
||||
self.tags.update(tags_dict)
|
||||
self.tags_to_attributes(self, tags_dict)
|
||||
@@ -816,7 +815,7 @@ class Matroska(core.AVContainer):
|
||||
try:
|
||||
value = [filter(item) for item in value] if isinstance(value, list) else filter(value)
|
||||
except Exception, e:
|
||||
log.warning('Failed to convert tag to core attribute: %s', e)
|
||||
log.warning(u'Failed to convert tag to core attribute: %r', e)
|
||||
# Special handling for tv series recordings. The 'title' tag
|
||||
# can be used for both the series and the episode name. The
|
||||
# same is true for trackno which may refer to the season
|
||||
|
||||
Reference in new issue
Block a user