fix: wrong creation of source types
This commit is contained in:
parent
017752c4d0
commit
98afe5047d
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -25,6 +25,7 @@
|
|||||||
"encyclopaedia",
|
"encyclopaedia",
|
||||||
"ENDC",
|
"ENDC",
|
||||||
"Gitea",
|
"Gitea",
|
||||||
|
"iframe",
|
||||||
"isrc",
|
"isrc",
|
||||||
"levenshtein",
|
"levenshtein",
|
||||||
"metallum",
|
"metallum",
|
||||||
|
@ -22,7 +22,7 @@ from ..utils import output, BColors
|
|||||||
from ..utils.string_processing import fit_to_file_system
|
from ..utils.string_processing import fit_to_file_system
|
||||||
from ..utils.config import youtube_settings, main_settings
|
from ..utils.config import youtube_settings, main_settings
|
||||||
from ..utils.path_manager import LOCATIONS
|
from ..utils.path_manager import LOCATIONS
|
||||||
from ..utils.enums import SourceType
|
from ..utils.enums import SourceType, ALL_SOURCE_TYPES
|
||||||
from ..utils.support_classes.download_result import DownloadResult
|
from ..utils.support_classes.download_result import DownloadResult
|
||||||
from ..utils.support_classes.query import Query
|
from ..utils.support_classes.query import Query
|
||||||
from ..utils.support_classes.download_result import DownloadResult
|
from ..utils.support_classes.download_result import DownloadResult
|
||||||
@ -148,7 +148,7 @@ class Pages:
|
|||||||
return data_object
|
return data_object
|
||||||
|
|
||||||
def fetch_from_url(self, url: str) -> Optional[DataObject]:
|
def fetch_from_url(self, url: str) -> Optional[DataObject]:
|
||||||
source = Source.match_url(url, SourceType.MANUAL)
|
source = Source.match_url(url, ALL_SOURCE_TYPES.MANUAL)
|
||||||
if source is None:
|
if source is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ class Pages:
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
def fetch_url(self, url: str, stop_at_level: int = 2) -> Tuple[Type[Page], DataObject]:
|
def fetch_url(self, url: str, stop_at_level: int = 2) -> Tuple[Type[Page], DataObject]:
|
||||||
source = Source.match_url(url, SourceType.MANUAL)
|
source = Source.match_url(url, ALL_SOURCE_TYPES.MANUAL)
|
||||||
|
|
||||||
if source is None:
|
if source is None:
|
||||||
raise UrlNotFoundException(url=url)
|
raise UrlNotFoundException(url=url)
|
||||||
|
@ -502,9 +502,18 @@ class Musify(Page):
|
|||||||
for video_container in video_container_list:
|
for video_container in video_container_list:
|
||||||
iframe_list: List[BeautifulSoup] = video_container.findAll("iframe")
|
iframe_list: List[BeautifulSoup] = video_container.findAll("iframe")
|
||||||
for iframe in iframe_list:
|
for iframe in iframe_list:
|
||||||
|
"""
|
||||||
|
the url could look like this
|
||||||
|
https://www.youtube.com/embed/sNObCkhzOYA?si=dNVgnZMBNVlNb0P_
|
||||||
|
"""
|
||||||
|
parsed_url = urlparse(iframe["src"])
|
||||||
|
path_parts = parsed_url.path.strip("/").split("/")
|
||||||
|
if path_parts[0] != "embed" or len(path_parts) < 2:
|
||||||
|
continue
|
||||||
|
|
||||||
source_list.append(Source(
|
source_list.append(Source(
|
||||||
SourceType.YOUTUBE,
|
ALL_SOURCE_TYPES.YOUTUBE,
|
||||||
iframe["src"],
|
f"https://music.youtube.com/watch?v={path_parts[1]}",
|
||||||
referrer_page=self.SOURCE_TYPE
|
referrer_page=self.SOURCE_TYPE
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ class YoutubeMusic(SuperYouTube):
|
|||||||
Artist(
|
Artist(
|
||||||
name=name,
|
name=name,
|
||||||
source_list=[Source(
|
source_list=[Source(
|
||||||
SourceType.YOUTUBE_MUSIC,
|
self.SOURCE_TYPE,
|
||||||
f"https://music.youtube.com/channel/{ydl_res.get('channel_id', ydl_res.get('uploader_id', ''))}"
|
f"https://music.youtube.com/channel/{ydl_res.get('channel_id', ydl_res.get('uploader_id', ''))}"
|
||||||
)]
|
)]
|
||||||
) for name in artist_names]
|
) for name in artist_names]
|
||||||
@ -641,7 +641,7 @@ class YoutubeMusic(SuperYouTube):
|
|||||||
artwork=Artwork(*ydl_res.get("thumbnails", [])),
|
artwork=Artwork(*ydl_res.get("thumbnails", [])),
|
||||||
main_artist_list=artist_list,
|
main_artist_list=artist_list,
|
||||||
source_list=[Source(
|
source_list=[Source(
|
||||||
SourceType.YOUTUBE_MUSIC,
|
self.SOURCE_TYPE,
|
||||||
f"https://music.youtube.com/watch?v={ydl_res.get('id')}"
|
f"https://music.youtube.com/watch?v={ydl_res.get('id')}"
|
||||||
), source],
|
), source],
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user