Merge pull request #276 from michael-lazar/expand_shortened_urls
Expand URLs.
This commit is contained in:
@@ -10,6 +10,7 @@ import warnings
|
|||||||
import six
|
import six
|
||||||
import praw
|
import praw
|
||||||
import tornado
|
import tornado
|
||||||
|
import requests
|
||||||
|
|
||||||
from . import docs
|
from . import docs
|
||||||
from .config import Config, copy_default_config, copy_default_mailcap
|
from .config import Config, copy_default_config, copy_default_mailcap
|
||||||
@@ -132,7 +133,13 @@ def main():
|
|||||||
|
|
||||||
# Open the supplied submission link before opening the subreddit
|
# Open the supplied submission link before opening the subreddit
|
||||||
if config['link']:
|
if config['link']:
|
||||||
page.open_submission(url=config['link'])
|
# Expand shortened urls like https://redd.it/
|
||||||
|
# Praw won't accept the shortened versions, add the reddit
|
||||||
|
# headers to avoid a 429 response from reddit.com
|
||||||
|
url = requests.head(config['link'], headers=reddit.http.headers,
|
||||||
|
allow_redirects=True).url
|
||||||
|
|
||||||
|
page.open_submission(url=url)
|
||||||
|
|
||||||
# Launch the subreddit page
|
# Launch the subreddit page
|
||||||
page.loop()
|
page.loop()
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class LoadScreen(object):
|
|||||||
|
|
||||||
EXCEPTION_MESSAGES = [
|
EXCEPTION_MESSAGES = [
|
||||||
(exceptions.RTVError, '{0}'),
|
(exceptions.RTVError, '{0}'),
|
||||||
(praw.errors.OAuthException, 'Not logged in'),
|
(praw.errors.OAuthException, 'OAuth Error'),
|
||||||
(praw.errors.OAuthScopeRequired, 'Not logged in'),
|
(praw.errors.OAuthScopeRequired, 'Not logged in'),
|
||||||
(praw.errors.LoginRequired, 'Not logged in'),
|
(praw.errors.LoginRequired, 'Not logged in'),
|
||||||
(praw.errors.InvalidCaptcha, 'Error, captcha required'),
|
(praw.errors.InvalidCaptcha, 'Error, captcha required'),
|
||||||
|
|||||||
Reference in New Issue
Block a user