diff --git a/bin/pandora_client b/bin/pandora_client index 30c7796..2b6d0dc 100755 --- a/bin/pandora_client +++ b/bin/pandora_client @@ -25,17 +25,12 @@ if __name__ == '__main__': parser.print_help() sys.exit() - if not args or args[0] not in ('scan', 'sync', 'clean'): - parser.error('you must specify a valid action. \n\t\tknown actions are: scan, sync, clean') + actions = ('scan', 'extract', 'sync', 'clean') + if not args or args[0] not in actions: + parser.error('you must specify a valid action. \n\t\tknown actions are: %s' % ', '.join(actions)) action = args[0] c = pandora_client.Client(opts.config) - if action == 'scan': - c.scan() - if action == 'sync': - c.sync() - if action == 'clean': - c.clean() - + getattr(c, action)() diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index 75f2c94..e546a8d 100644 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -160,6 +160,33 @@ class Client(object): c.execute('UPDATE file SET deleted=? WHERE path=?', (deleted, f)) conn.commit() + def extract(self): + conn, c = self._conn() + + volumes = {} + for name in self._config['volumes']: + path = self._config['volumes'][name] + path = os.path.normpath(path) + + volumes[name] = {} + volumes[name]['path'] = path + if os.path.exists(path): + volumes[name]['available'] = True + else: + volumes[name]['available'] = False + + #profile = self.api.encodingProfile()['data']['profile'] + profile = '480p' + for name in volumes: + if volumes[name]['available']: + prefix = volumes[name]['path'] + files = self.files(prefix) + for f in files['files']: + filename = os.path.join(prefix, f['path']) + if 'video' in files['info'][f['oshash']] and files['info'][f['oshash']]['video']: + print filename.encode('utf-8') + i = encode(filename, self.media_cache(), profile) + def sync(self): conn, c = self._conn() diff --git a/pandora_client/extract.py b/pandora_client/extract.py index f848856..16162f7 100644 --- a/pandora_client/extract.py +++ b/pandora_client/extract.py @@ -26,6 +26,14 @@ def frame(video, target, position): if fdir and not os.path.exists(fdir): os.makedirs(fdir) + ''' + #oxframe + cmd = ['oxframe', '-i', video, '-p', str(position), '-o', target] + print cmd + r = run_command(cmd) + return r == 0 + ''' + #mplayer cwd = os.getcwd() target = os.path.abspath(target) @@ -125,6 +133,7 @@ def video(video, target, profile, info): '-vb', '%dk'%bitrate, '-g', '%d' % int(fps*2), '-s', '%dx%d'%(width, height), '-aspect', aspect, + '-deinterlace', ] cmd = ['ffmpeg', '-y', '-threads', '2', '-i', video] \ + audio_settings \