feat: renamed referrer page fixing typo
This commit is contained in:
parent
3eba8e90f4
commit
aa50d2cf20
@ -4,6 +4,7 @@ from collections import defaultdict
|
||||
from enum import Enum
|
||||
from typing import List, Dict, Set, Tuple, Optional, Iterable
|
||||
from urllib.parse import urlparse
|
||||
from dataclasses import dataclass
|
||||
|
||||
from ..utils.enums.source import SourcePages, SourceTypes
|
||||
from ..utils.config import youtube_settings
|
||||
@ -14,11 +15,12 @@ from .parents import OuterProxy
|
||||
from .collection import Collection
|
||||
|
||||
|
||||
|
||||
@dataclass
|
||||
class Source(OuterProxy):
|
||||
url: str
|
||||
|
||||
page_enum: SourcePages
|
||||
referer_page: SourcePages
|
||||
referrer_page: SourcePages
|
||||
|
||||
audio_url: str
|
||||
|
||||
@ -27,16 +29,16 @@ class Source(OuterProxy):
|
||||
}
|
||||
|
||||
# This is automatically generated
|
||||
def __init__(self, page_enum: SourcePages, url: str, referer_page: SourcePages = None, audio_url: str = None,
|
||||
def __init__(self, page_enum: SourcePages, url: str, referrer_page: SourcePages = None, audio_url: str = None,
|
||||
**kwargs) -> None:
|
||||
|
||||
if referer_page is None:
|
||||
referer_page = page_enum
|
||||
if referrer_page is None:
|
||||
referrer_page = page_enum
|
||||
|
||||
super().__init__(url=url, page_enum=page_enum, referer_page=referer_page, audio_url=audio_url, **kwargs)
|
||||
super().__init__(url=url, page_enum=page_enum, referrer_page=referrer_page, audio_url=audio_url, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def match_url(cls, url: str, referer_page: SourcePages) -> Optional["Source"]:
|
||||
def match_url(cls, url: str, referrer_page: SourcePages) -> Optional["Source"]:
|
||||
"""
|
||||
this shouldn't be used, unlesse you are not certain what the source is for
|
||||
the reason is that it is more inefficient
|
||||
@ -45,38 +47,38 @@ class Source(OuterProxy):
|
||||
url = parsed.geturl()
|
||||
|
||||
if "musify" in parsed.netloc:
|
||||
return cls(SourcePages.MUSIFY, url, referer_page=referer_page)
|
||||
return cls(SourcePages.MUSIFY, url, referrer_page=referrer_page)
|
||||
|
||||
if parsed.netloc in [_url.netloc for _url in youtube_settings['youtube_url']]:
|
||||
return cls(SourcePages.YOUTUBE, url, referer_page=referer_page)
|
||||
return cls(SourcePages.YOUTUBE, url, referrer_page=referrer_page)
|
||||
|
||||
if url.startswith("https://www.deezer"):
|
||||
return cls(SourcePages.DEEZER, url, referer_page=referer_page)
|
||||
return cls(SourcePages.DEEZER, url, referrer_page=referrer_page)
|
||||
|
||||
if url.startswith("https://open.spotify.com"):
|
||||
return cls(SourcePages.SPOTIFY, url, referer_page=referer_page)
|
||||
return cls(SourcePages.SPOTIFY, url, referrer_page=referrer_page)
|
||||
|
||||
if "bandcamp" in url:
|
||||
return cls(SourcePages.BANDCAMP, url, referer_page=referer_page)
|
||||
return cls(SourcePages.BANDCAMP, url, referrer_page=referrer_page)
|
||||
|
||||
if "wikipedia" in parsed.netloc:
|
||||
return cls(SourcePages.WIKIPEDIA, url, referer_page=referer_page)
|
||||
return cls(SourcePages.WIKIPEDIA, url, referrer_page=referrer_page)
|
||||
|
||||
if url.startswith("https://www.metal-archives.com/"):
|
||||
return cls(SourcePages.ENCYCLOPAEDIA_METALLUM, url, referer_page=referer_page)
|
||||
return cls(SourcePages.ENCYCLOPAEDIA_METALLUM, url, referrer_page=referrer_page)
|
||||
|
||||
# the less important once
|
||||
if url.startswith("https://www.facebook"):
|
||||
return cls(SourcePages.FACEBOOK, url, referer_page=referer_page)
|
||||
return cls(SourcePages.FACEBOOK, url, referrer_page=referrer_page)
|
||||
|
||||
if url.startswith("https://www.instagram"):
|
||||
return cls(SourcePages.INSTAGRAM, url, referer_page=referer_page)
|
||||
return cls(SourcePages.INSTAGRAM, url, referrer_page=referrer_page)
|
||||
|
||||
if url.startswith("https://twitter"):
|
||||
return cls(SourcePages.TWITTER, url, referer_page=referer_page)
|
||||
return cls(SourcePages.TWITTER, url, referrer_page=referrer_page)
|
||||
|
||||
if url.startswith("https://myspace.com"):
|
||||
return cls(SourcePages.MYSPACE, url, referer_page=referer_page)
|
||||
return cls(SourcePages.MYSPACE, url, referrer_page=referrer_page)
|
||||
|
||||
def get_song_metadata(self) -> Metadata:
|
||||
return Metadata({
|
||||
|
@ -185,7 +185,7 @@ class Bandcamp(Page):
|
||||
if li is None and li['href'] is not None:
|
||||
continue
|
||||
|
||||
source_list.append(Source.match_url(_parse_artist_url(li['href']), referer_page=self.SOURCE_TYPE))
|
||||
source_list.append(Source.match_url(_parse_artist_url(li['href']), referrer_page=self.SOURCE_TYPE))
|
||||
|
||||
return Artist(
|
||||
name=name,
|
||||
|
@ -486,7 +486,7 @@ class EncyclopaediaMetallum(Page):
|
||||
|
||||
href = anchor["href"]
|
||||
if href is not None:
|
||||
source_list.append(Source.match_url(href, referer_page=self.SOURCE_TYPE))
|
||||
source_list.append(Source.match_url(href, referrer_page=self.SOURCE_TYPE))
|
||||
|
||||
# The following code is only legacy code, which I just kep because it doesn't harm.
|
||||
# The way ma returns sources changed.
|
||||
@ -504,7 +504,7 @@ class EncyclopaediaMetallum(Page):
|
||||
if url is None:
|
||||
continue
|
||||
|
||||
source_list.append(Source.match_url(url, referer_page=self.SOURCE_TYPE))
|
||||
source_list.append(Source.match_url(url, referrer_page=self.SOURCE_TYPE))
|
||||
|
||||
return source_list
|
||||
|
||||
|
@ -503,7 +503,7 @@ class Musify(Page):
|
||||
source_list.append(Source(
|
||||
SourcePages.YOUTUBE,
|
||||
iframe["src"],
|
||||
referer_page=self.SOURCE_TYPE
|
||||
referrer_page=self.SOURCE_TYPE
|
||||
))
|
||||
|
||||
return Song(
|
||||
@ -812,7 +812,7 @@ class Musify(Page):
|
||||
href = additional_source.get("href")
|
||||
if href is None:
|
||||
continue
|
||||
new_src = Source.match_url(href, referer_page=self.SOURCE_TYPE)
|
||||
new_src = Source.match_url(href, referrer_page=self.SOURCE_TYPE)
|
||||
if new_src is None:
|
||||
continue
|
||||
source_list.append(new_src)
|
||||
|
Loading…
Reference in New Issue
Block a user