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` @@ -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)
* [python-bitcoinrpc](https://pypi.python.org/pypi/python-bitcoinrpc/)
* [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

8
feed2twister.conf.example

@ -20,7 +20,13 @@ feeds = https://swatwt.com/favs/rss/en @@ -20,7 +20,13 @@ feeds = https://swatwt.com/favs/rss/en
logging_level = debug
# we don't want to flood more than that in a single run.
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
# tell is.gd to publicly show statistics for the shortened url
shortener_stats = True

15
feed2twister.py

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

Loading…
Cancel
Save