Browse Source

add filtering of invalid audio tracks out, it really doesn't help that

much...

keep items in original order which is numerical order, if we sort them,
we end up w/ the 10-19 between 1 and 2 which is anoying.. especially
w/ track switch...

[git-p4: depot-paths = "//depot/": change = 835]
v0.3
John-Mark Gurney 19 years ago
parent
commit
52684cb144
1 changed files with 17 additions and 15 deletions
  1. +17
    -15
      dvd.py

+ 17
- 15
dvd.py View File

@@ -2,9 +2,15 @@


'''DVD Handling''' '''DVD Handling'''


default_audio_lang = 'en'

import os import os
import sets import sets


import sys
sys.path.append('/Users/jgurney/p4/bktrau/info')
import mpegts

from pydvdread import * from pydvdread import *


from DIDLLite import StorageFolder, Movie, VideoItem, Resource from DIDLLite import StorageFolder, Movie, VideoItem, Resource
@@ -83,7 +89,7 @@ class DVDChapterResource(resource.Resource):
def render(self, request): def render(self, request):
request.setHeader('content-type', 'video/mpeg') request.setHeader('content-type', 'video/mpeg')


request.setHeader('content-length', str(self.getFileSize()))
#request.setHeader('content-length', str(self.getFileSize()))
if request.method == 'HEAD': if request.method == 'HEAD':
return '' return ''


@@ -98,12 +104,14 @@ class DVDChapter(VideoItem):
self.chapter = kwargs['chapter'] self.chapter = kwargs['chapter']
del kwargs['dvdtitle'], kwargs['chapter'] del kwargs['dvdtitle'], kwargs['chapter']


kwargs['content'] = DVDChapterResource(self.chapter)
audio = self.dvdtitle.selectaudio(default_audio_lang)
kwargs['content'] = DVDChapterResource(mpegts.DVDAudioFilter(
self.chapter, 0x80 + audio.pos))
VideoItem.__init__(self, *args, **kwargs) VideoItem.__init__(self, *args, **kwargs)


self.url = '%s/%s' % (self.cd.urlbase, self.id) self.url = '%s/%s' % (self.cd.urlbase, self.id)
self.res = Resource(self.url, 'http-get:*:video/mpeg:*') self.res = Resource(self.url, 'http-get:*:video/mpeg:*')
self.res.size = self.chapter.size
#self.res.size = self.chapter.size


def doUpdate(self): def doUpdate(self):
pass pass
@@ -126,8 +134,8 @@ class DVDTitle(StorageFolder):


def doUpdate(self): def doUpdate(self):
doupdate = False doupdate = False
children, toindex = gennameindexes('Chapter', self.dvdtitle)
children = sets.Set(children)
origchildren, toindex = gennameindexes('Chapter', self.dvdtitle)
children = sets.Set(origchildren)
for i in self.pathObjmap.keys(): for i in self.pathObjmap.keys():
if i not in children: if i not in children:
doupdate = True doupdate = True
@@ -135,7 +143,7 @@ class DVDTitle(StorageFolder):
self.cd.delItem(self.pathObjmap[i]) self.cd.delItem(self.pathObjmap[i])
del self.pathObjmap[i] del self.pathObjmap[i]


for i in children:
for i in origchildren:
if i in self.pathObjmap: if i in self.pathObjmap:
continue continue


@@ -145,9 +153,6 @@ class DVDTitle(StorageFolder):
chapter = self.dvdtitle[toindex[i]]) chapter = self.dvdtitle[toindex[i]])
doupdate = True doupdate = True


# sort our children
self.sort(lambda x, y: cmp(x.title, y.title))

if doupdate: if doupdate:
StorageFolder.doUpdate(self) StorageFolder.doUpdate(self)


@@ -168,8 +173,8 @@ class DVDDisc(FSObject, StorageFolder):
self.dvd = DVD(self.FSpath) self.dvd = DVD(self.FSpath)


doupdate = False doupdate = False
children, toindex = gennameindexes('Title', self.dvd)
children = sets.Set(children)
origchildren, toindex = gennameindexes('Title', self.dvd)
children = sets.Set(origchildren)
for i in self.pathObjmap.keys(): for i in self.pathObjmap.keys():
if i not in children: if i not in children:
doupdate = True doupdate = True
@@ -177,7 +182,7 @@ class DVDDisc(FSObject, StorageFolder):
self.cd.delItem(self.pathObjmap[i]) self.cd.delItem(self.pathObjmap[i])
del self.pathObjmap[i] del self.pathObjmap[i]


for i in children:
for i in origchildren:
if i in self.pathObjmap: if i in self.pathObjmap:
continue continue


@@ -186,9 +191,6 @@ class DVDDisc(FSObject, StorageFolder):
i, dvdtitle = self.dvd[toindex[i]], dvddisc = self) i, dvdtitle = self.dvd[toindex[i]], dvddisc = self)
doupdate = True doupdate = True


# sort our children
self.sort(lambda x, y: cmp(x.title, y.title))

if doupdate: if doupdate:
StorageFolder.doUpdate(self) StorageFolder.doUpdate(self)




Loading…
Cancel
Save