Browse Source

Fix bug when use_shortener is "False", document ur1.ca etc.

master
The Dod 10 years ago
parent
commit
4691f72792
  1. 2
      README.md
  2. 8
      feed2twister.conf.example
  3. 15
      feed2twister.py

2
README.md

@ -15,7 +15,7 @@ edit it so that it contains similar settings to those you had at `conf.py`
* [Twister](http://twister.net.co/) (of course) * [Twister](http://twister.net.co/) (of course)
* [python-bitcoinrpc](https://pypi.python.org/pypi/python-bitcoinrpc/) * [python-bitcoinrpc](https://pypi.python.org/pypi/python-bitcoinrpc/)
* [feedparser](https://pypi.python.org/pypi/feedparser/) * [feedparser](https://pypi.python.org/pypi/feedparser/)
* [gdshortener](https://github.com/torre76/gd_shortener/) (optional) * URL shortener dependencies (see `use_shortener` at `feedparser.conf.example`)
### Installing ### Installing

8
feed2twister.conf.example

@ -20,7 +20,13 @@ feeds = https://swatwt.com/favs/rss/en
logging_level = debug logging_level = debug
# we don't want to flood more than that in a single run. # we don't want to flood more than that in a single run.
max_new_items_per_feed = 3 max_new_items_per_feed = 3
# to enable this, you need gdshortener: https://github.com/torre76/gd_shortener/ # use_shortener (case insensitive):
# * False [default] - no shortener
# * Is.gd [or True (for backward-compatibility)] -- Dependencies:
# * https://github.com/torre76/gd_shortener
# * Ur1.ca [Less tor-hostile] -- Dependencies:
# * https://github.com/legoktm/ur1
# * https://github.com/MiCHiLU/python-functools32
use_shortener = False use_shortener = False
# tell is.gd to publicly show statistics for the shortened url # tell is.gd to publicly show statistics for the shortened url
shortener_stats = True shortener_stats = True

15
feed2twister.py

@ -43,14 +43,11 @@ if 'logging_level' in main_config and main_config['logging_level']:
logging.basicConfig(level=log_level) logging.basicConfig(level=log_level)
# region shorteners # url shorteners
if 'use_shortener' not in main_config or not main_config['use_shortener']: shortener = str(main_config.get('use_shortener', 'false')).lower()
shorten = lambda url: url
shortener = str(main_config['use_shortener']).lower()
# is.gd is the default # is.gd is the default (for historical reasons, but they're tor-user hostile :( )
if shortener in ['isgd', 'is.gd', 'gd', 'true', 'yes', 't', '1']: if shortener in ['isgd', 'is.gd', 'gd', 'true', 'yes', 'y', '1']:
import gdshortener import gdshortener
shorten = \ shorten = \
lambda url: gdshortener.ISGDShortener().shorten(url=url, log_stat=get_bool_conf_option('shortener_stats'))[0] lambda url: gdshortener.ISGDShortener().shorten(url=url, log_stat=get_bool_conf_option('shortener_stats'))[0]
@ -61,8 +58,10 @@ elif shortener in ['v', 'vgd', 'v.gd']:
elif shortener in ['ur1', 'ur1.ca', 'ur1ca']: elif shortener in ['ur1', 'ur1.ca', 'ur1ca']:
import ur1 import ur1
shorten = lambda url: ur1.shorten(url) shorten = lambda url: ur1.shorten(url)
elif shortener in ['false', 'no', 'n', '0']:
shorten = lambda url: url
else: else:
logging.error('Invalid configuration for "shortener"!') logging.error('Invalid configuration for "use_shortener"!')
sys.exit(10) sys.exit(10)
# endregion # endregion

Loading…
Cancel
Save