layed out the complete fetching of album

This commit is contained in:
Hellow 2023-03-20 21:50:19 +01:00
parent 96f2d7ef6e
commit f39c3c11ad
3 changed files with 207 additions and 568 deletions

View File

@ -21,13 +21,8 @@
soup.find("div", {"id": "bodyContent"}) soup.find("div", {"id": "bodyContent"})
--> -->
<body data-ma-theme="blue-grey"> <body data-ma-theme="blue-grey"><main class="main main--alt"><section class="content content--full"><div class="row content__inner">
<main class="main main--alt">
<section class="content content--full">
<div class="row content__inner">
<div id="bodyContent" class="content__inner--sm col-md-12 col-lg-9"> <div id="bodyContent" class="content__inner--sm col-md-12 col-lg-9">
<!--if breadcrumb list has 4 elements--> <!--if breadcrumb list has 4 elements-->
<!--the -2 is the artist link: the li-a-span has the tag "content="3""--> <!--the -2 is the artist link: the li-a-span has the tag "content="3""-->
<!--the -1 is the album on, which also has the class "active", which can be tested--> <!--the -1 is the album on, which also has the class "active", which can be tested-->
@ -53,14 +48,14 @@
<li class="breadcrumb-item active">Hybrid Theory</li> <li class="breadcrumb-item active">Hybrid Theory</li>
</ol> </ol>
<!--the proper informations for source and album name--> <!--the proper information for source and album name-->
<meta content="/release/linkin-park-hybrid-theory-2000-188" itemprop="url" /> <meta content="/release/linkin-park-hybrid-theory-2000-188" itemprop="url" />
<meta content="Hybrid Theory" itemprop="name" /> <meta content="Hybrid Theory" itemprop="name" />
<!-- <!--
parsing the header seems like a nightmare, but if I don't find the date (year) parsing the header seems like a nightmare, but if I don't find the date (year)
in another place, I will take it from here. in another place, I will take it from here.
I'll probaply just implement it I'll probably just implement it or I dunno
--> -->
<header class="content__title"> <header class="content__title">
<h1>Linkin Park - Hybrid Theory (2000)</h1> <h1>Linkin Park - Hybrid Theory (2000)</h1>
@ -146,15 +141,21 @@
</div> </div>
<div class="playlist__details"> <div class="playlist__details">
<div class="playlist__heading"> <div class="playlist__heading">
<a href="/artist/linkin-park-5" rel="nofollow">Linkin Park</a> - <a class="strong" href="/track/linkin-park-papercut-3051">Papercut</a> <span itemprop="byArtist" itemscope="itemscope" itemtype="http://schema.org/MusicGroup"> <a href="/artist/linkin-park-5" rel="nofollow">Linkin Park</a> - <a class="strong" href="/track/linkin-park-papercut-3051">Papercut</a>
<span itemprop="byArtist" itemscope="itemscope" itemtype="http://schema.org/MusicGroup">
<meta content="/artist/linkin-park-5" itemprop="url" /> <meta content="/artist/linkin-park-5" itemprop="url" />
<meta content="Linkin Park" itemprop="name" /> <meta content="Linkin Park" itemprop="name" />
</span> </span>
</div> </div>
</div> </div>
<div><div class="track__details track__rating hidden-xs-down"> <div>
<span class="text-muted"><i class="zmdi zmdi-star-circle zmdi-hc-1-3x" title="Рейтинг"></i> 326,3K</span> <div class="track__details track__rating hidden-xs-down">
</div></div> <span class="text-muted">
<i class="zmdi zmdi-star-circle zmdi-hc-1-3x" title="Рейтинг"></i>
326,3K
</span>
</div>
</div>
<div class="track__details hidden-xs-down"> <div class="track__details hidden-xs-down">
<span class="text-muted">03:05</span> <span class="text-muted">03:05</span>
<span class="text-muted">320 Кб/с</span> <span class="text-muted">320 Кб/с</span>
@ -165,10 +166,14 @@
</div> </div>
<div class="playlist__actions"> <div class="playlist__actions">
<span class="pl-btn save-to-pl" id="add_3051" title="Сохранить в плейлист"><i class="zmdi zmdi-plus zmdi-hc-1-5x"></i></span> <span class="pl-btn save-to-pl" id="add_3051" title="Сохранить в плейлист"><i class="zmdi zmdi-plus zmdi-hc-1-5x"></i></span>
<a target="_blank" itemprop="audio" download="Linkin Park - Papercut.mp3" href="/track/dl/3051/linkin-park-papercut.mp3" class="no-ajaxy yaBrowser" id="dl_3051" title='Скачать Linkin Park - Papercut'><span><i class="zmdi zmdi-download zmdi-hc-2-5x"></i></span></a> <a target="_blank" itemprop="audio" download="Linkin Park - Papercut.mp3" href="/track/dl/3051/linkin-park-papercut.mp3" class="no-ajaxy yaBrowser" id="dl_3051" title='Скачать Linkin Park - Papercut'>
<span><i class="zmdi zmdi-download zmdi-hc-2-5x"></i></span>
</a>
</div>
</div>
</div>
</div>
<div id="playerDiv3052" class="playlist__item" itemprop="track" itemscope="itemscope" itemtype="http://schema.org/MusicRecording" data-artist="Linkin Park" data-name="One Step Closer"> <div id="playerDiv3052" class="playlist__item" itemprop="track" itemscope="itemscope" itemtype="http://schema.org/MusicRecording" data-artist="Linkin Park" data-name="One Step Closer">
<div id="play_3052" class="playlist__control play" data-url="/track/play/3052/linkin-park-one-step-closer.mp3" data-position="2" data-title="Linkin Park - One Step Closer" title="Слушать Linkin Park - One Step Closer"> <div id="play_3052" class="playlist__control play" data-url="/track/play/3052/linkin-park-one-step-closer.mp3" data-position="2" data-title="Linkin Park - One Step Closer" title="Слушать Linkin Park - One Step Closer">
<span class="ico-play"><i class="zmdi zmdi-play-circle-outline zmdi-hc-2-5x"></i></span> <span class="ico-play"><i class="zmdi zmdi-play-circle-outline zmdi-hc-2-5x"></i></span>
@ -796,398 +801,10 @@
</div> </div>
</div> </div>
</div>
</div>
</div>
<div class="text-center mb-3">
<center><a class="badge badge-primary mb-1" data-ma-action="aside-open" data-ma-target=".user-login-summary" href="#">отключить рекламу</a></center>
<div id="MF_musify_D_728x90" style="max-width:825px; margin: auto;"></div>
</div>
Залогиньтесь для того чтобы проголосовать за альбом
<select id="rating" data-rating="9.08" data-url="/release/vote/" data-id="188" data-readonly="true">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<p class="text-muted rating-count">Всего голосов: 784</p>
<div class="card">
<div class="card-body">
<h3 class="card-title">Другие альбомы исполнителя Linkin Park</h3>
<div class="card-deck">
<div data-type="0" class="card release-thumbnail">
<a href="/release/linkin-park-wastelands-2014-508334">
<img class="card-img-top lozad" data-src="https://40s.musify.club/img/69/7395270/20806785.jpg" alt="Wastelands" />
<noscript><img src="https://40s.musify.club/img/69/7395270/20806785.jpg" alt="Wastelands" /></noscript>
</a>
<div class="card-body">
<h3 class="card-title">
<a href="/artist/linkin-park-5">Linkin Park</a> </h3>
<h4 class="card-subtitle"><a href="/release/linkin-park-wastelands-2014-508334">Wastelands</a></h4>
</div>
<div class="card-footer">
<p class="card-text"><a href="/albums/2014">2014</a></p>
</div>
<div class="card-footer">
<p class="card-text genre__labels">
<a href="/genre/alternative-metal-17">Alternative Metal</a><a href="/genre/rapcore-38">Rapcore</a> </p>
</div>
<div class="card-footer">
<small><i class="zmdi zmdi-calendar" title="Добавлено"></i> 01.06.2014</small>
<small><i class="zmdi zmdi-star zmdi-hc-fw" title="Рейтинг"></i> 6,79</small>
</div>
</div><div data-type="0" class="card release-thumbnail">
<a href="/release/linkin-park-lpu10-2010-106107">
<img class="card-img-top lozad" data-src="https://41s-a.musify.club/img/70/1058780/40332317.jpg" alt="LPU10" />
<noscript><img src="https://41s-a.musify.club/img/70/1058780/40332317.jpg" alt="LPU10" /></noscript>
</a>
<div class="card-body">
<h3 class="card-title">
<a href="/artist/linkin-park-5">Linkin Park</a> </h3>
<h4 class="card-subtitle"><a href="/release/linkin-park-lpu10-2010-106107">LPU10</a></h4>
</div>
<div class="card-footer">
<p class="card-text"><a href="/albums/2010">2010</a></p>
</div>
<div class="card-footer">
<p class="card-text genre__labels">
<a href="/genre/alternative-metal-17">Alternative Metal</a> </p>
</div>
<div class="card-footer">
<small><i class="zmdi zmdi-calendar" title="Добавлено"></i> 08.11.2010</small>
<small><i class="zmdi zmdi-star zmdi-hc-fw" title="Рейтинг"></i> 5,47</small>
</div>
</div><div data-type="0" class="card release-thumbnail">
<a href="/release/linkin-park-demos-2000-18630">
<img class="card-img-top lozad" data-src="https://41s-a.musify.club/img/70/786536/40605763.jpg" alt="Demos" />
<noscript><img src="https://41s-a.musify.club/img/70/786536/40605763.jpg" alt="Demos" /></noscript>
</a>
<div class="card-body">
<h3 class="card-title">
<a href="/artist/linkin-park-5">Linkin Park</a> </h3>
<h4 class="card-subtitle"><a href="/release/linkin-park-demos-2000-18630">Demos</a></h4>
</div>
<div class="card-footer">
<p class="card-text"><a href="/albums/2000">2000</a></p>
</div>
<div class="card-footer">
<p class="card-text genre__labels">
<a href="/genre/nu-metal-36">Nu-Metal</a> </p>
</div>
<div class="card-footer">
<small><i class="zmdi zmdi-calendar" title="Добавлено"></i> 04.08.2008</small>
<small><i class="zmdi zmdi-star zmdi-hc-fw" title="Рейтинг"></i> 8,81</small>
</div>
</div></div> </div></div>
</div> </div>
</div> </div>
<div class="messages">
<div class="messages__body">
<div class="messages__header">
<div class="toolbar toolbar--inner mb-0">
<div class="toolbar__label">Комментарии</div>
</div>
</div>
<a id="new"></a>
<div class="messages__reply">
</div>
<div class="messages__content inf-scroll" id="messages">
<div class="messages__item ">
<img src="https://38s.musify.club/img/68/22210529/57471442.jpg" alt="Харамаки Зоро" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">Харамаки Зоро</small>
</div>
<p>Весьма симпатишно. <br/>Сочетание ярости с лиризмом и грустью. <br/>Кажется логичным продолжением RATM, правда не такое качевое.</p>
</div>
</div>
<div class="messages__item ">
<img src="https://38s.musify.club/img/68/22063914/57334365.jpg" alt="germanost" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">germanost</small>
</div>
<p>Хи, хи хардер чего овцой прикидываешься.. Смущаешь юные умы.. <img src='/images/Smiles/s18.gif' alt=''></img> <img src='/images/Smiles/s70.gif' alt=''></img></p>
</div>
</div>
<div class="messages__item ">
<img src="https://41s.musify.club/img/68/27084662/67311114.jpg" alt="TradeShark1" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">TradeShark1</small>
</div>
<p>Я бы рекомендовал бы вам послушать Дельфина, Токио, Красная плесень, они не далеко от Линкин Парк, только интереснее, изобретательнее, драйвовее, мелодичнее. Ну ещё Bestie Boys. Они все намного круче. Потом спасибо мне скажите &#128521;</p>
</div>
</div>
<div class="messages__item ">
<img src="https://41s.musify.club/img/68/27084662/67311114.jpg" alt="TradeShark1" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">TradeShark1</small>
</div>
<p>Послушал, слабенькая группа, одну мелодию на весь альбом. Красная плесень намного круче, у них хотя бы разнообразие в музыке, много красивых мелодий, сотни красивых песен. Такова реальность. Думаю фанатам Линкин Парк зайдёт Красная плесень в таком же стиле, но более мелодично</p>
</div>
</div>
<div class="messages__item ">
<img src="https://41s-a.musify.club/img/70/14592985/37156016.jpg" alt="way" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">way</small>
</div>
<p>Лучший их альбом и нет лучше. Все песни тут огонь!</p>
</div>
</div>
<div class="messages__item ">
<img src="https://38s-a.musify.club/img/71/23700912/60277424.jpg" alt="Dungeon Freestyler" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">Dungeon Freestyler</small>
</div>
<p>Не зацепили только High Voltage, Pushing Me Away, Cure For The Itch. Остальное просто улет! <img src='/Content/Smiles/116-music.svg' height='24' alt=''></img></p>
</div>
</div>
<div class="messages__item ">
<img src="https://37s.musify.club/img/69/25626482/64245309.jpg" alt="goreThrasher" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">goreThrasher</small>
</div>
<p>}{уйня какая-то</p>
</div>
</div>
<div class="messages__item ">
<img src="https://sun1-23.userapi.com/impg/j_BJpAzLJsSDC9uVJCMG3vqaYcqeWaKnVafEjA/OlbyQXoH5QI.jpg?size=50x0&amp;quality=96&amp;crop=0,54,341,341&amp;sign=dd4937bc43dae396ce5a09a9525431bb&amp;c_uniq_tag=La2cobtZGUiWM5NK7bcV9R3AQz7u-Y9NGzWkNklXppI&amp;ava=1" alt="Владислав Владислав" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">Владислав Владислав</small>
</div>
<p>Самый лучший альбом Линкинов!<br/>Лучшие треки:<br/>Papercut <br/>One Step Closer <br/>Crawling <br/>Runaway <br/>In the End <br/>Pushing Me Away</p>
</div>
</div>
<div class="messages__item ">
<img src="https://39s-a.musify.club/img/70/5855975/17875592.jpg" alt="insane Hwo" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">insane Hwo</small>
</div>
<p>В детстве казались намного тяжелее. Сейчас слушается как легенькая поп-музыка.</p>
</div>
</div>
<div class="messages__item ">
<img src="/images/default-ava.png" alt="Hi123" class="avatar-img">
<div class="messages__details">
<div class="messages__actions">
<small class="name">Hi123</small>
</div>
<p>Этот альбом шедевр на все времена!</p>
</div>
</div>
<a class="d-none pagination__next" rel="nofollow" href="/albumcomment/messagelistajax/188?page=2"></a>
</div>
<div class="text-center page-load-status m-5">
<div class="spinner-grow infinite-scroll-request d-none" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
</div>
</div>
<div id="MF_musify_D_Billboard"></div>
</div>
<div class="left-sidebar hidden-md-down col-lg-3">
<div class="card">
<div class="card-body">
<h3 class="card-title">Популярные исполнители</h3>
<div class="listview listview--hover top-uploaders">
<a class="listview__item" href="/artist/korol-i-shut-76588">
<img src="https://40s-a.musify.club/img/70/25412682/63792162.jpg" class="listview__img lozad" alt="Король и Шут">
<div class="listview__content">
<div class="listview__heading">Король и Шут</div>
<p>2676 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/leningrad-71003">
<img src="https://40s-a.musify.club/img/70/25412665/63792119.jpg" class="listview__img lozad" alt="Ленинград">
<div class="listview__content">
<div class="listview__heading">Ленинград</div>
<p>1690 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/pink-floyd-235">
<img src="https://39s-a.musify.club/img/71/21606334/54844322.jpg" class="listview__img lozad" alt="Pink Floyd">
<div class="listview__content">
<div class="listview__heading">Pink Floyd</div>
<p>8325 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/linkin-park-5">
<img src="https://39s.musify.club/img/68/25102361/62958672.jpg" class="listview__img lozad" alt="Linkin Park">
<div class="listview__content">
<div class="listview__heading">Linkin Park</div>
<p>9761 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/kino-25537">
<img src="https://37s.musify.club/img/69/25969238/64947758.jpg" class="listview__img lozad" alt="Кино">
<div class="listview__content">
<div class="listview__heading">Кино</div>
<p>5809 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/david-guetta-608">
<img src="https://39s.musify.club/img/68/21602761/54836062.jpg" class="listview__img lozad" alt="David Guetta">
<div class="listview__content">
<div class="listview__heading">David Guetta</div>
<p>3115 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/grigorii-leps-97816">
<img src="https://39s.musify.club/img/69/21563345/54758019.jpg" class="listview__img lozad" alt="Григорий Лепс">
<div class="listview__content">
<div class="listview__heading">Григорий Лепс</div>
<p>1816 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/deep-purple-1190">
<img src="https://39s.musify.club/img/68/21602843/54836167.jpg" class="listview__img lozad" alt="Deep Purple">
<div class="listview__content">
<div class="listview__heading">Deep Purple</div>
<p>6459 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/vladimir-visotskii-90531">
<img src="https://38s.musify.club/img/68/21638788/54903095.jpg" class="listview__img lozad" alt="Владимир Высоцкий">
<div class="listview__content">
<div class="listview__heading">Владимир Высоцкий</div>
<p>9234 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/imany-96002">
<img src="https://37s.musify.club/img/69/25246613/63347914.jpg" class="listview__img lozad" alt="Imany">
<div class="listview__content">
<div class="listview__heading">Imany</div>
<p>246 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/the-prodigy-27233">
<img src="https://38s-a.musify.club/img/70/18365891/48153351.jpg" class="listview__img lozad" alt="The Prodigy">
<div class="listview__content">
<div class="listview__heading">The Prodigy</div>
<p>2492 треков</p>
</div>
</a>
<a class="listview__item" href="/artist/ariya-70285">
<img src="https://38s.musify.club/img/68/23501229/59855504.jpg" class="listview__img lozad" alt="Ария">
<div class="listview__content">
<div class="listview__heading">Ария</div>
<p>2293 треков</p>
</div>
</a>
</div>
<a href="/artist" class="view-more">Все исполнители</a>
</div>
</div>
<div class="card">
<div class="card-body">
<h3 class="card-title">Популярные жанры</h3>
<div class="genre__labels">
<a href="/genre/hard-rock-28">#Hard Rock</a><a href="/genre/pop-11">#Pop</a><a href="/genre/disco-25">#Disco</a><a href="/genre/heavy-metal-30">#Heavy Metal</a><a href="/genre/rock-1">#Rock</a><a href="/genre/blues-rock-158">#Blues Rock</a><a href="/genre/eurodance-234">#Eurodance</a><a href="/genre/trance-12">#Trance</a><a href="/genre/synthpop-21">#Synthpop</a><a href="/genre/rap-8">#Rap</a><a href="/genre/thrash-metal-67">#Thrash Metal</a><a href="/genre/ost-229">#OST</a><a href="/genre/russkii-shanson-267">#Русский шансон</a><a href="/genre/power-metal-75">#Power Metal</a><a href="/genre/progressive-rock-53">#Progressive Rock</a><a href="/genre/blues-62">#Blues</a><a href="/genre/alternative-rock-14">#Alternative Rock</a><a href="/genre/electronic-2">#Electronic</a><a href="/genre/jazz-51">#Jazz</a><a href="/genre/new-age-58">#New Age</a> </div>
<a href="/genre" class="view-more">Все жанры</a>
</div>
</div>
<center><a class="badge badge-primary mb-1" data-ma-action="aside-open" data-ma-target=".user-login-summary" href="#">отключить рекламу</a></center>
<a href="https://goodhit.me/new/" target="_blank"><img data-src="/images/ads/rbt.jpg" class="lozad"><noscript><img src="/images/ads/rbt.jpg" /></noscript></a>
</div>
</div> </div>
</section> </section>
<footer class="footer">
<p>© Musify - 2023</p>
<ul class="nav footer__nav">
<li><a class="nav-link" href="mailto:admin@musify.club">admin@musify.club</a></li>
<li><span class="nav-link internal-link" data-sub="L2ZlZWRiYWNr">Обратная связь</span></li>
<li><span class="nav-link internal-link" data-sub="L2FidXNl">Жалоба / DMCA</span></li>
<li><span class="nav-link internal-link" data-sub="L2NvbnRhY3RzL2xlZ2Fs">Правовая информация</span></li>
<li><span class="nav-link internal-link" data-sub="L3Rlcm1z">Пользовательское соглашение</span></li>
<li><span class="nav-link internal-link" data-sub="aHR0cHM6Ly9yLmludGVyYWt0LnJ1L2Fzc2V0cy9kb2NzL29waXNhbmllLXVzbHVnLnBkZg==">Описание услуг</span></li>
</ul>
<p>
ООО «АдвМьюзик» заключил лицензионные соглашения с крупнейшими российскими правообладателями на использование музыкальных произведений. <span class="internal-link" data-sub="L2NvbnRhY3RzL2xlZ2Fs">Полная информация</span>
</p>
</footer>
<footer class="player-footer d-none">
<div id="jp_container_N" class="container-fluid">
<div class="jp-type-playlist">
<div id="jplayer_N" class="jp-jplayer"></div>
<div class="jp-gui">
<div class="jp-interface">
<div class="jp-controls">
<div><span class="jp-replay"><i class="zmdi zmdi-replay-10 zmdi-hc-4x"></i></span></div>
<div>
<span class="jp-play"><i class="zmdi zmdi-play-circle-outline zmdi-hc-4x"></i></span>
<span class="jp-pause"><i class="zmdi zmdi-pause-circle-outline zmdi-hc-4x"></i></span>
</div>
<div><span class="jp-next"><i class="zmdi zmdi-skip-next zmdi-hc-4x"></i></span></div>
<div><span class="jp-forward"><i class="zmdi zmdi-forward-10 zmdi-hc-4x"></i></span></div>
<div class="jp-progress jp-seek-bar progress">
<div class="jp-play-bar progress-bar" role="progressbar"></div>
<div class="jp-title-container">
<div class="jp-title jp-details"></div>
</div>
</div>
<ul class="list-unstyled jp-duration-container">
<li class="jp-current-time text-muted"></li>
<li class="jp-duration"></li>
</ul>
<div>
<span class="jp-mute"><i class="zmdi zmdi-volume-up zmdi-hc-4x"></i></span>
<span class="jp-unmute"><i class="zmdi zmdi-volume-off zmdi-hc-4x"></i></span>
</div>
<div class="jp-volume jp-volume-bar progress">
<div class="jp-volume-bar-value progress-bar"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</footer>
</main> </main>
</body> </body>
</html>

View File

@ -60,6 +60,7 @@ X-Requested-With: XMLHttpRequest
class MusifyTypes(Enum): class MusifyTypes(Enum):
ARTIST = "artist" ARTIST = "artist"
RELEASE = "release"
@dataclass @dataclass
@ -85,6 +86,30 @@ class Musify(Page):
SOURCE_TYPE = SourcePages.MUSIFY SOURCE_TYPE = SourcePages.MUSIFY
@classmethod
def parse_url(cls, url: str) -> MusifyUrl:
parsed = urlparse(url)
path = parsed.path.split("/")
split_name = path[2].split("-")
url_id = split_name[-1]
name_for_url = "-".join(split_name[:-1])
try:
type_enum = MusifyTypes(path[1])
except ValueError as e:
print(f"{path[1]} is not yet implemented, add it to MusifyTypes")
raise e
return MusifyUrl(
source_type=type_enum,
name_without_id=name_for_url,
name_with_id=path[2],
musify_id=url_id,
url=url
)
@classmethod @classmethod
def search_by_query(cls, query: str) -> Options: def search_by_query(cls, query: str) -> Options:
query_obj = cls.Query(query) query_obj = cls.Query(query)
@ -358,24 +383,6 @@ class Musify(Page):
return Options(search_results) return Options(search_results)
@classmethod
def parse_url(cls, url: str) -> MusifyUrl:
parsed = urlparse(url)
path = parsed.path.split("/")
split_name = path[2].split("-")
url_id = split_name[-1]
name_for_url = "-".join(split_name[:-1])
return MusifyUrl(
source_type=MusifyTypes(path[1]),
name_without_id=name_for_url,
name_with_id=path[2],
musify_id=url_id,
url=url
)
@classmethod @classmethod
def parse_album_card(cls, album_card: BeautifulSoup, artist_name: str = None) -> Album: def parse_album_card(cls, album_card: BeautifulSoup, artist_name: str = None) -> Album:
""" """
@ -706,7 +713,7 @@ class Musify(Page):
fetches artist from source fetches artist from source
[x] discography [x] discography
[x] attributes *(name and country... wooooow and I waste one request for this)* [x] attributes
[] picture gallery [] picture gallery
Args: Args:
@ -728,14 +735,27 @@ class Musify(Page):
@classmethod @classmethod
def fetch_album_from_source(cls, source: Source, flat: bool = False) -> Album: def fetch_album_from_source(cls, source: Source, flat: bool = False) -> Album:
"""_summary_
Args:
source (Source): _description_
flat (bool, optional): _description_. Defaults to False.
Returns:
Album: _description_
""" """
fetches album from source:
eg. 'https://musify.club/release/linkin-park-hybrid-theory-2000-188'
/html/musify/album_overview.html
[] tracklist
[] attributes *(name and country... wooooow and I waste one request for this)*
[] ratings
:param source:
:param flat:
:return:
"""
url = cls.parse_url(source.url)
endpoint = cls.HOST + "/release/" + url.name_with_id
r = cls.get_request(endpoint)
if r is None:
return Album()
soup = BeautifulSoup(r.content, "html.parser")
return Album(title="works") return Album(title="works")

View File

@ -15,9 +15,11 @@ def fetch_artist():
artist = Musify.fetch_details(artist) artist = Musify.fetch_details(artist)
print(artist.options) print(artist.options)
def fetch_album(): def fetch_album():
album = objects.Album( album = objects.Album(
source_list=[objects.Source(objects.SourcePages.MUSIFY, "https://musify.club/release/linkin-park-hybrid-theory-2000-188")] source_list=[objects.Source(objects.SourcePages.MUSIFY,
"https://musify.club/release/linkin-park-hybrid-theory-2000-188")]
) )
album = Musify.fetch_details(album) album = Musify.fetch_details(album)