diff --git a/mbz_rss_service/config.py b/mbz_rss_service/config.py index c9efed6..f9a17af 100644 --- a/mbz_rss_service/config.py +++ b/mbz_rss_service/config.py @@ -14,6 +14,7 @@ CACHE_DIR = os.path.expandvars(os.environ.get('CACHE_DIR', '/var/mbz-rss-feeder/ MB_APP_NAME = os.path.expandvars(os.environ.get('MB_APP_NAME', 'mbz-rss-service')) MB_VERSION = os.path.expandvars(os.environ.get('MB_VERSION', '1')) MB_CONTACT = os.path.expandvars(os.environ.get('MB_CONTACT', 'someone@somewhere.com')) +MBZ_SERVICE_BASE_URL = os.path.expandvars(os.environ.get('MBZ_SERVICE_BASE_URL', 'http://mbz-rss-feeder:8080')) # file system dir check if not os.path.exists(CACHE_DIR): @@ -41,6 +42,8 @@ class Config: self.MB_APP_NAME = MB_APP_NAME self.MB_VERSION = MB_VERSION self.MB_CONTACT = MB_CONTACT + self.MBZ_SERVICE_BASE_URL = MBZ_SERVICE_BASE_URL + try: with open(os.path.join(os.path.dirname(__file__), '..', 'VERSION')) as f: self.VERSION = f.read().strip() diff --git a/mbz_rss_service/main.py b/mbz_rss_service/main.py index aa1e53b..78fb6fb 100644 --- a/mbz_rss_service/main.py +++ b/mbz_rss_service/main.py @@ -72,6 +72,10 @@ logger.info(f" - MusicBrainz Log Level: {mbz_log_level_str}") musicbrainz.init_musicbrainz() app = Flask(__name__) +@app.context_processor +def inject_service_name(): + return {'service_base_url': config.MBZ_SERVICE_BASE_URL} + class ReverseProxied(object): def __init__(self, app): self.app = app diff --git a/mbz_rss_service/musicbrainz.py b/mbz_rss_service/musicbrainz.py index 3dff102..fc4d0b0 100644 --- a/mbz_rss_service/musicbrainz.py +++ b/mbz_rss_service/musicbrainz.py @@ -109,7 +109,7 @@ def get_artist_relation_links(relationlist): target = rel.get('target') if not target: continue - if re.match(r'^https://.*imdb\.com', target): + if re.match(r'^https://([^/]+\.)?imdb\.com', target): links['IMDb'] = target elif re.match(r'^https://music\.apple\.com', target): links['apple'] = target @@ -117,11 +117,11 @@ def get_artist_relation_links(relationlist): links['amazon'] = target elif re.match(r'^https://open\.spotify\.com', target): links['spotify'] = target - elif re.match(r'^https://.*qobuz\.com', target): + elif re.match(r'^https://([^/]+\.)?qobuz\.com', target): links['qobuz'] = target - elif re.match(r'^https://.*deezer\.com', target): + elif re.match(r'^https://([^/]+\.)?deezer\.com', target): links['deezer'] = target - elif re.match(r'^https://.*beatport\.com', target): + elif re.match(r'^https://([^/]+\.)?beatport\.com', target): links['beatport'] = target return links diff --git a/mbz_rss_service/templates/index.html b/mbz_rss_service/templates/index.html index 839c9bc..8e33db4 100644 --- a/mbz_rss_service/templates/index.html +++ b/mbz_rss_service/templates/index.html @@ -11,7 +11,7 @@ ({{ feed.artists|length }})
- RSS + RSS | service rss