better extract and file locating

This commit is contained in:
j 2012-01-04 12:31:43 +05:30
parent ed79ad9097
commit 28462d5f85
3 changed files with 29 additions and 7 deletions

View File

@ -25,16 +25,13 @@ if __name__ == '__main__':
parser.print_help()
sys.exit()
actions = ('scan', 'sync', 'upload', 'extract', 'clean', 'cmd')
actions = ('scan', 'sync', 'upload', 'extract', 'extract_offline', 'clean', 'cmd')
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]
if action == 'extract':
offline = True
else:
offline = False
offline = False
c = pandora_client.Client(opts.config, offline)
getattr(c, action)(args[1:])

View File

@ -3,6 +3,7 @@
"profile": "480p.webm",
"username": "username", "password": "password",
"cache": "~/.ox/client.sqlite",
"media-cache": "~/.ox/media",
"volumes": {
"my videos": "/home/example/Movies"
}

View File

@ -225,7 +225,28 @@ class Client(object):
print "scanned volume %s: %s files, %s new, %s deleted" % (
name, len(files), len(files) - len(known_files), len(deleted_files))
def extract(self, args):
def extract(self):
if not self.user:
print "you need to login"
return
conn, c = self._conn()
#send empty list to get updated list of requested info/files/data
post = {'info': {}}
r = self.api.update(post)
if r['data']['data']:
print 'encoding %s videos' % len(r['data']['data'])
for oshash in r['data']['data']:
data = {}
for path in self.path(oshash):
if os.path.exists(path):
info = self.info(oshash)
print path.encode('utf-8')
i = encode(path, self.media_cache(), self.profile, info)
break
def extract_offline(self):
conn, c = self._conn()
volumes = {}
@ -342,6 +363,7 @@ class Client(object):
for path in self.path(oshash):
if os.path.exists(path):
self.api.uploadData(path, oshash)
break
if r['data']['data']:
print 'encoding and uploading %s videos' % len(r['data']['data'])
@ -350,10 +372,12 @@ class Client(object):
for path in self.path(oshash):
if os.path.exists(path):
info = self.info(oshash)
if not self.api.uploadVideo(path, data, self.profile, info):
if not self.api.uploadVideo(path,
data, self.profile, info):
if not self.signin():
print "failed to login again"
return
break
def files(self, prefix):
conn, c = self._conn()