From b950c187f4639570f6740d086627057917808915 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 2 Mar 2014 13:52:31 +0100 Subject: [PATCH] add option to force rescan all files --- pandora_client/__init__.py | 7 ++++--- pandora_client/utils.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index 6754af0..3837005 100644 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -342,7 +342,7 @@ class Client(object): else: self.set_encodes(site, files) - def scan_file(self, path): + def scan_file(self, path, rescan=False): conn, c = self._conn() update = True @@ -357,8 +357,8 @@ class Client(object): created = row[4] update = False break - if update: - info = utils.avinfo(path) + if update or rescan: + info = utils.avinfo(path, cached=not rescan) ''' if 'error' in info or info['size'] == 0: #print info @@ -470,6 +470,7 @@ class Client(object): return volumes def scan(self, args): + rescan = '--rescan' in args print "checking for new files ..." volumes = self.active_volumes() for name in sorted(volumes): diff --git a/pandora_client/utils.py b/pandora_client/utils.py index ee81331..3a661aa 100644 --- a/pandora_client/utils.py +++ b/pandora_client/utils.py @@ -39,9 +39,9 @@ class AspectRatio(fractions.Fraction): def ratio(self): return "%d:%d" % (self.numerator, self.denominator) -def avinfo(filename): +def avinfo(filename, cached=True): 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 not 'display_aspect_ratio' in info['video'][0]: dar = AspectRatio(info['video'][0]['width'], info['video'][0]['height'])