diff --git a/common/scraper.py b/common/scraper.py index 89bdb363..02770ab2 100644 --- a/common/scraper.py +++ b/common/scraper.py @@ -46,7 +46,7 @@ scraper_registry = {} def log_url(func): """ Catch exceptions and log then pass the exceptions. - First postion argument of decorated function must be the url. + First postion argument (except cls/self) of decorated function must be the url. """ @functools.wraps(func) def wrapper(*args, **kwargs): @@ -54,7 +54,7 @@ def log_url(func): return func(*args, **kwargs) except Exception as e: # log the url - logger.error(f"Scrape Failed URL: {args[0]}") + logger.error(f"Scrape Failed URL: {args[1]}") logger.error(str(e)) raise e @@ -102,10 +102,10 @@ class AbstractScraper: @classmethod def get_effective_url(cls, raw_url): - url = cls.regex.findall(raw_url)[0] + url = cls.regex.findall(raw_url) if not url: raise ValueError("not valid url") - return url + return url[0] @classmethod def download_page(cls, url, headers): diff --git a/mastodon/api.py b/mastodon/api.py index 0de77994..f7a1678d 100644 --- a/mastodon/api.py +++ b/mastodon/api.py @@ -4,7 +4,7 @@ import random import functools from django.core.exceptions import ObjectDoesNotExist from boofilsic.settings import MASTODON_TIMEOUT -from boofilsic.settings import CLIENT_NAME, APP_WEBSITE +from boofilsic.settings import CLIENT_NAME, APP_WEBSITE, REDIRECT_URIS from .models import CrossSiteUserInfo # See https://docs.joinmastodon.org/methods/accounts/ @@ -98,13 +98,13 @@ def create_app(domain_name): payload = { 'client_name': CLIENT_NAME, 'scopes': 'read write follow', - 'redirect_uris': f'{APP_WEBSITE}/users/OAuth2_login/', + 'redirect_uris': REDIRECT_URIS, 'website': APP_WEBSITE } from boofilsic.settings import DEBUG if DEBUG: - payload['redirect_uris'] = 'http://localhost/users/OAuth2_login/' + payload['redirect_uris'] = 'http://localhost/users/OAuth2_login/\nurn:ietf:wg:oauth:2.0:oob' response = post(url, data=payload) return response