1
0
mirror of https://github.com/fraoustin/piwigotools.git synced 2025-06-07 16:06:27 +00:00

add upload in sync

This commit is contained in:
fraoustin 2016-02-18 20:48:34 +01:00
parent 61f3387008
commit 3063af3482
2 changed files with 13 additions and 1 deletions

View File

@ -114,7 +114,10 @@ class Piwigo(piwigo.Piwigo):
""" """
return list of file name image for path return list of file name image for path
""" """
kw["cat_id"]= self.idcategory(path) try:
kw["cat_id"]= self.idcategory(path)
except PiwigoExistException:
return {}
kw["per_page"] = 200 kw["per_page"] = 200
kw["page"] = 0 kw["page"] = 0
imgs = {} imgs = {}

View File

@ -3,6 +3,7 @@
import sys import sys
import os, os.path import os, os.path
import glob import glob
import fnmatch
import pprint import pprint
try: try:
@ -69,6 +70,7 @@ VERBS = {
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"}, "user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
"password" : {"type":"string", "default":"", "help":"password of piwigo gallery"}, "password" : {"type":"string", "default":"", "help":"password of piwigo gallery"},
"thread" : {"type":"int", "default":"1", "help":"number of thread"}, "thread" : {"type":"int", "default":"1", "help":"number of thread"},
"extension" : {"type":"string", "default":"*.JPG", "help":"extension for upload"},
}, },
}, },
"ws": "ws":
@ -213,6 +215,13 @@ def main():
# treatment # treatment
run = Run(verb, options.thread) run = Run(verb, options.thread)
kw = purge_kw(options.__dict__,('user','password','url','source','category','thread')) kw = purge_kw(options.__dict__,('user','password','url','source','category','thread'))
for root, dirnames, filenames in os.walk(options.source):
for filename in fnmatch.filter(filenames, options.extension):
path = os.path.abspath(os.path.join(root, filename))[len(options.source)+1:]
if not piwigo.isimage(path.replace(os.sep, ' / ')):
category = ' / '.join(path.split(os.sep)[:-1])
run.add(piwigo.makedirs,[category,], kw)
run.add(piwigo.upload,[path, category], kw)
ana.stop() ana.stop()
except Exception as e: except Exception as e:
ana.stop() ana.stop()