add option to force rescan all files

This commit is contained in:
j 2014-03-02 13:52:31 +01:00
parent 91a85ebbc4
commit b950c187f4
2 changed files with 6 additions and 5 deletions

View file

@ -342,7 +342,7 @@ class Client(object):
else: else:
self.set_encodes(site, files) self.set_encodes(site, files)
def scan_file(self, path): def scan_file(self, path, rescan=False):
conn, c = self._conn() conn, c = self._conn()
update = True update = True
@ -357,8 +357,8 @@ class Client(object):
created = row[4] created = row[4]
update = False update = False
break break
if update: if update or rescan:
info = utils.avinfo(path) info = utils.avinfo(path, cached=not rescan)
''' '''
if 'error' in info or info['size'] == 0: if 'error' in info or info['size'] == 0:
#print info #print info
@ -470,6 +470,7 @@ class Client(object):
return volumes return volumes
def scan(self, args): def scan(self, args):
rescan = '--rescan' in args
print "checking for new files ..." print "checking for new files ..."
volumes = self.active_volumes() volumes = self.active_volumes()
for name in sorted(volumes): for name in sorted(volumes):

View file

@ -39,9 +39,9 @@ class AspectRatio(fractions.Fraction):
def ratio(self): def ratio(self):
return "%d:%d" % (self.numerator, self.denominator) return "%d:%d" % (self.numerator, self.denominator)
def avinfo(filename): def avinfo(filename, cached=True):
if os.path.getsize(filename): if os.path.getsize(filename):
info = ox.avinfo(filename) info = ox.avinfo(filename, cached=cached)
if 'video' in info and info['video'] and 'width' in info['video'][0]: if 'video' in info and info['video'] and 'width' in info['video'][0]:
if not 'display_aspect_ratio' in info['video'][0]: if not 'display_aspect_ratio' in info['video'][0]:
dar = AspectRatio(info['video'][0]['width'], info['video'][0]['height']) dar = AspectRatio(info['video'][0]['width'], info['video'][0]['height'])