forked from Raptor123471/DingoLingo
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from solaluset/suno
add Suno support
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import re | ||
|
||
from yt_dlp import DownloadError | ||
from yt_dlp.extractor.common import InfoExtractor | ||
|
||
|
||
class SunoAIIE(InfoExtractor): | ||
_VALID_URL = r"^https?://app\.suno\.ai/song/(?P<code>\w+)" | ||
|
||
def _real_extract(self, url): | ||
from musicbot.loader import _loop | ||
from musicbot.linkutils import get_soup | ||
|
||
match = re.match(self._VALID_URL, url) | ||
try: | ||
soup = _loop.run_until_complete(get_soup(url)) | ||
return { | ||
"id": match.group("code"), | ||
"url": soup.find(property="og:audio")["content"], | ||
"title": re.sub(r" \| Suno$", "", soup.find("title").string), | ||
"thumbnail": soup.find(property="og:image")["content"], | ||
} | ||
except Exception as e: | ||
raise DownloadError(str(e)) from e |