Improve plugin update.

This commit is contained in:
Bastian Kleineidam 2013-05-22 22:29:03 +02:00
parent ef878eed7c
commit 23e6a8923d
9 changed files with 115 additions and 82 deletions

View file

@ -4,6 +4,7 @@
Script to get arcamax comics and save the info in a JSON file for further processing.
"""
from __future__ import print_function
import codecs
import re
import sys
import os
@ -75,14 +76,17 @@ def has_comic(name):
def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips."""
min_comics, filename = args
with codecs.open(filename, 'a', 'utf-8') as fp:
for name, shortname in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
if has_comic(name):
prefix = '#'
prefix = u'#'
else:
prefix = ''
print("%sadd(%r, %r)" % (prefix, str(truncate_name(name)), str(shortname)))
prefix = u''
fp.write(u"%sadd(%r, %r)\n" % (prefix, str(truncate_name(name)),
str(shortname)))
if __name__ == '__main__':

View file

@ -4,6 +4,7 @@
Script to get arcamax comics and save the info in a JSON file for further processing.
"""
from __future__ import print_function
import codecs
import re
import sys
import os
@ -296,7 +297,9 @@ def has_comic(name):
def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips."""
min_comics = int(args[0])
min_comics, filename = args
min_comics = int(min_comics)
with codecs.open(filename, 'a', 'utf-8') as fp:
for name, entry in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
@ -304,10 +307,10 @@ def print_results(args):
if num < min_comics:
continue
if has_comic(name):
prefix = '#'
prefix = u'#'
else:
prefix = ''
print("%sadd(%r, %r, %r)" % (
prefix = u''
fp.write(u"%sadd(%r, %r, %r)\n" % (
prefix, str(truncate_name(name)), str(url), desc
))

View file

@ -5,6 +5,7 @@ Script to get a list of ComicGenesis comics and save the info in a
JSON file for further processing.
"""
from __future__ import print_function
import codecs
import re
import sys
import os
@ -429,7 +430,9 @@ def has_comic(name):
def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips."""
min_comics = int(args[0])
min_comics, filename = args
min_comics = int(min_comics)
with codecs.open(filename, 'a', 'utf-8') as fp:
for name, entry in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
@ -438,10 +441,12 @@ def print_results(args):
continue
url = url.replace("comicgen.com", "comicgenesis.com")
if has_comic(name):
prefix = '#'
prefix = u'#'
else:
prefix = ''
print("%sadd(%r, %r)" % (prefix, str(truncate_name(name)), str(url)))
prefix = u''
fp.write(u"%sadd(%r, %r)\n" % (
prefix, str(truncate_name(name)), str(url))
)
if __name__ == '__main__':

View file

@ -5,6 +5,7 @@ Script to get a list of creators.com comics and save the info in a JSON file for
"""
from __future__ import print_function
import re
import codecs
import sys
import os
import requests
@ -64,14 +65,18 @@ def has_gocomics_comic(name):
def print_results(args):
"""Print comics."""
min_comics, filename = args
with codecs.open(filename, 'a', 'utf-8') as fp:
for name, url in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
if has_gocomics_comic(name):
prefix = '# duplicate of gocomics '
prefix = u'# duplicate of gocomics '
else:
prefix = ''
print("%sadd(%r, %r)" % (prefix, str(truncate_name(name)), str(url)))
prefix = u''
fp.write(u"%sadd(%r, %r)\n" % (
prefix, str(truncate_name(name)), str(url))
)
if __name__ == '__main__':

View file

@ -4,6 +4,7 @@
Script to get a list of drunkduck comics and save the info in a JSON file for further processing.
"""
from __future__ import print_function
import codecs
import re
import sys
import os
@ -205,18 +206,22 @@ def get_results():
save_result(res, json_file)
def print_results(min_strips):
def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips."""
min_comics, filename = args
min_comics = int(min_comics)
with codecs.open(filename, 'a', 'utf-8') as fp:
for name, entry in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
path, num = entry
if num >= min_strips:
print("add(%r, %r)" % (str(truncate_name(name)), str(path)))
if num >= min_comics:
fp.write(u"add(%r, %r)\n" % (
str(truncate_name(name)), str(path)))
if __name__ == '__main__':
if len(sys.argv) > 1:
print_results(int(sys.argv[1]))
print_results(sys.argv[1:])
else:
get_results()

View file

@ -4,6 +4,7 @@
Script to get a list of gocomics and save the info in a JSON file for further processing.
"""
from __future__ import print_function
import codecs
import re
import sys
import os
@ -97,10 +98,14 @@ def get_results():
def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips."""
min_comics, filename = args
with codecs.open(filename, 'a', 'utf-8') as fp:
for name, shortname in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
print("add(%r, %r)" % (str(truncate_name(name)), str(shortname)))
fp.write(u"add(%r, %r)\n" % (
str(truncate_name(name)), str(shortname))
)
if __name__ == '__main__':

View file

@ -5,6 +5,7 @@ Script to get a list of KeenSpot comics and save the info in a
JSON file for further processing.
"""
from __future__ import print_function
import codecs
import re
import sys
import os
@ -122,18 +123,20 @@ def has_comic(name):
def print_results(args):
"""Print all comics."""
min_comics, filename = args
with codecs.open(filename, 'a', 'utf-8') as fp:
for name, entry in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
url, desc = entry
if has_comic(name):
prefix = '#'
prefix = u'#'
else:
prefix = ''
name = truncate_name(name).encode('utf-8')
url = url.encode('utf-8')
desc = desc.encode('utf-8')
print("%sadd(%r, %r, %r)" % (prefix, name, url, desc))
prefix = u''
name = truncate_name(name)
fp.write(u"%sadd(%r, %r, %r)\n" % (
prefix, str(name), str(url), desc)
)
if __name__ == '__main__':

View file

@ -4,6 +4,7 @@
Script to get a list of smackjeeves.com comics and save the info in a JSON file for further processing.
"""
from __future__ import print_function
import codecs
import re
import sys
import os
@ -317,7 +318,9 @@ def has_comic(name):
def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips."""
min_comics = int(args[0])
min_comics, filename = args
min_comics = int(min_comics)
with codecs.open(filename, 'a', 'utf-8') as fp:
for name, entry in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
@ -325,10 +328,10 @@ def print_results(args):
if num < min_comics:
continue
if has_comic(name):
prefix = '#'
prefix = u'#'
else:
prefix = ''
print("%sadd(%r, %r, %r, %s, %s)" % (
prefix = u''
fp.write(u"%sadd(%r, %r, %r, %s, %s)\n" % (
prefix, str(truncate_name(name)), str(url), desc, adult, bounce
))

View file

@ -15,5 +15,5 @@ for script in $list; do
target="${d}/../dosagelib/plugins/${script}.py"
echo "Upating $target"
"${d}/removeafter.py" "$target" "# DO NOT REMOVE"
"${d}/${script}.py" $mincomics >> "$target"
"${d}/${script}.py" $mincomics "$target"
done