diff --git a/README.md b/README.md index 10386bc..02a6ad5 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Once *feediverse* is configured you can add it to your crontab: */15 * * * * /usr/local/bin/feediverse -Run `feediverse --help` to show the comand line options. +Run `feediverse --help` to show the command line options. ## Post Format diff --git a/feediverse.py b/feediverse.py index f3836a7..b08e7bd 100755 --- a/feediverse.py +++ b/feediverse.py @@ -28,8 +28,6 @@ def __urlencodereplace_errors(exc): codecs.register_error("urlencodereplace", __urlencodereplace_errors) -DEFAULT_CONFIG_FILE = os.path.join("~", ".feediverse") - def main(): parser = argparse.ArgumentParser() parser.add_argument("-n", "--dry-run", action="store_true", @@ -37,12 +35,15 @@ def main(): "don't toot, don't save config")) parser.add_argument("-v", "--verbose", action="store_true", help="be verbose") - parser.add_argument("config_file", nargs="?", metavar="CONFIG-FILE", - help=("config file to use, default: %s" % - DEFAULT_CONFIG_FILE), + parser.add_argument("-c", "--config", + help="config file to use", default=os.path.expanduser(DEFAULT_CONFIG_FILE)) + args = parser.parse_args() - config_file = args.config_file + config_file = args.config + + if args.verbose: + print("using config file", config_file) if not os.path.isfile(config_file): setup(config_file) @@ -88,7 +89,7 @@ def main(): print("trial run, not saving the config") else: if args.verbose: - print("saving the config") + print("saving the config", config_file) save_config(config, config_file) def save_config(config, config_file): @@ -140,10 +141,10 @@ def collect_images(entry, generator=None): soup = BeautifulSoup(part, 'html.parser') for tag in soup.find_all(["a", "img"]): if tag.name == "a": - url = tag["href"] + url = tag.get("href") elif tag.name == "img": - url = tag["src"] - if url not in urls: + url = tag.get("src") + if url and url not in urls: urls.append(url) urls = [] diff --git a/setup.py b/setup.py index d5e8b5c..50fc9b5 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md") as f: setup( name='feediverse', - version='0.1.4', + version='0.2.0', python_requires='>=3.3', url='https://github.com/edsu/feediverse', author='Ed Summers',