mirror of
https://github.com/twisterarmy/feed2twister.git
synced 2025-02-01 01:24:21 +00:00
Fix bug when use_shortener is "False", document ur1.ca etc.
This commit is contained in:
parent
addc35330c
commit
4691f72792
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
# url shorteners
|
||||
shortener = str(main_config.get('use_shortener', 'false')).lower()
|
||||
|
||||
shortener = str(main_config['use_shortener']).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']:
|
||||
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…
x
Reference in New Issue
Block a user