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

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. JSON file for further processing.
""" """
from __future__ import print_function from __future__ import print_function
import codecs
import re import re
import sys import sys
import os import os
@ -429,19 +430,23 @@ def has_comic(name):
def print_results(args): def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips.""" """Print all comics that have at least the given number of minimum comic strips."""
min_comics = int(args[0]) min_comics, filename = args
for name, entry in sorted(load_result(json_file).items()): min_comics = int(min_comics)
if name in exclude_comics: with codecs.open(filename, 'a', 'utf-8') as fp:
continue for name, entry in sorted(load_result(json_file).items()):
url, num = entry if name in exclude_comics:
if num < min_comics: continue
continue url, num = entry
url = url.replace("comicgen.com", "comicgenesis.com") if num < min_comics:
if has_comic(name): continue
prefix = '#' url = url.replace("comicgen.com", "comicgenesis.com")
else: if has_comic(name):
prefix = '' prefix = u'#'
print("%sadd(%r, %r)" % (prefix, str(truncate_name(name)), str(url))) else:
prefix = u''
fp.write(u"%sadd(%r, %r)\n" % (
prefix, str(truncate_name(name)), str(url))
)
if __name__ == '__main__': 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 from __future__ import print_function
import re import re
import codecs
import sys import sys
import os import os
import requests import requests
@ -64,14 +65,18 @@ def has_gocomics_comic(name):
def print_results(args): def print_results(args):
"""Print comics.""" """Print comics."""
for name, url in sorted(load_result(json_file).items()): min_comics, filename = args
if name in exclude_comics: with codecs.open(filename, 'a', 'utf-8') as fp:
continue for name, url in sorted(load_result(json_file).items()):
if has_gocomics_comic(name): if name in exclude_comics:
prefix = '# duplicate of gocomics ' continue
else: if has_gocomics_comic(name):
prefix = '' prefix = u'# duplicate of gocomics '
print("%sadd(%r, %r)" % (prefix, str(truncate_name(name)), str(url))) else:
prefix = u''
fp.write(u"%sadd(%r, %r)\n" % (
prefix, str(truncate_name(name)), str(url))
)
if __name__ == '__main__': 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. Script to get a list of drunkduck comics and save the info in a JSON file for further processing.
""" """
from __future__ import print_function from __future__ import print_function
import codecs
import re import re
import sys import sys
import os import os
@ -205,18 +206,22 @@ def get_results():
save_result(res, json_file) 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.""" """Print all comics that have at least the given number of minimum comic strips."""
for name, entry in sorted(load_result(json_file).items()): min_comics, filename = args
if name in exclude_comics: min_comics = int(min_comics)
continue with codecs.open(filename, 'a', 'utf-8') as fp:
path, num = entry for name, entry in sorted(load_result(json_file).items()):
if num >= min_strips: if name in exclude_comics:
print("add(%r, %r)" % (str(truncate_name(name)), str(path))) continue
path, num = entry
if num >= min_comics:
fp.write(u"add(%r, %r)\n" % (
str(truncate_name(name)), str(path)))
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) > 1: if len(sys.argv) > 1:
print_results(int(sys.argv[1])) print_results(sys.argv[1:])
else: else:
get_results() 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. Script to get a list of gocomics and save the info in a JSON file for further processing.
""" """
from __future__ import print_function from __future__ import print_function
import codecs
import re import re
import sys import sys
import os import os
@ -97,10 +98,14 @@ def get_results():
def print_results(args): def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips.""" """Print all comics that have at least the given number of minimum comic strips."""
for name, shortname in sorted(load_result(json_file).items()): min_comics, filename = args
if name in exclude_comics: with codecs.open(filename, 'a', 'utf-8') as fp:
continue for name, shortname in sorted(load_result(json_file).items()):
print("add(%r, %r)" % (str(truncate_name(name)), str(shortname))) if name in exclude_comics:
continue
fp.write(u"add(%r, %r)\n" % (
str(truncate_name(name)), str(shortname))
)
if __name__ == '__main__': 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. JSON file for further processing.
""" """
from __future__ import print_function from __future__ import print_function
import codecs
import re import re
import sys import sys
import os import os
@ -122,18 +123,20 @@ def has_comic(name):
def print_results(args): def print_results(args):
"""Print all comics.""" """Print all comics."""
for name, entry in sorted(load_result(json_file).items()): min_comics, filename = args
if name in exclude_comics: with codecs.open(filename, 'a', 'utf-8') as fp:
continue for name, entry in sorted(load_result(json_file).items()):
url, desc = entry if name in exclude_comics:
if has_comic(name): continue
prefix = '#' url, desc = entry
else: if has_comic(name):
prefix = '' prefix = u'#'
name = truncate_name(name).encode('utf-8') else:
url = url.encode('utf-8') prefix = u''
desc = desc.encode('utf-8') name = truncate_name(name)
print("%sadd(%r, %r, %r)" % (prefix, name, url, desc)) fp.write(u"%sadd(%r, %r, %r)\n" % (
prefix, str(name), str(url), desc)
)
if __name__ == '__main__': 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. 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 from __future__ import print_function
import codecs
import re import re
import sys import sys
import os import os
@ -317,20 +318,22 @@ def has_comic(name):
def print_results(args): def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips.""" """Print all comics that have at least the given number of minimum comic strips."""
min_comics = int(args[0]) min_comics, filename = args
for name, entry in sorted(load_result(json_file).items()): min_comics = int(min_comics)
if name in exclude_comics: with codecs.open(filename, 'a', 'utf-8') as fp:
continue for name, entry in sorted(load_result(json_file).items()):
url, num, desc, adult, bounce = entry if name in exclude_comics:
if num < min_comics: continue
continue url, num, desc, adult, bounce = entry
if has_comic(name): if num < min_comics:
prefix = '#' continue
else: if has_comic(name):
prefix = '' prefix = u'#'
print("%sadd(%r, %r, %r, %s, %s)" % ( else:
prefix, str(truncate_name(name)), str(url), desc, adult, bounce prefix = u''
)) fp.write(u"%sadd(%r, %r, %r, %s, %s)\n" % (
prefix, str(truncate_name(name)), str(url), desc, adult, bounce
))
if __name__ == '__main__': if __name__ == '__main__':

View file

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