Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Spotify Songs/Playlists #87

Merged
merged 2 commits into from
Jan 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions musicbot/linkutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+")

session = aiohttp.ClientSession(
headers={'User-Agent': 'python-requests/2.20.0'})
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36'})


def clean_sclink(track):
Expand All @@ -33,7 +33,9 @@ async def convert_spotify(url):

if re.search(url_regex, url):
result = url_regex.search(url)
url = result.group(0)

if "?si=" in url:
url = result.group(0) + "&nd=1"

async with session.get(url) as response:

Expand Down Expand Up @@ -98,7 +100,7 @@ async def get_spotify_playlist(url):
if config.SPOTIFY_ID != "" or config.SPOTIFY_SECRET != "":
print("ERROR: Check spotify CLIENT_ID and SECRET")

async with session.get(url) as response:
async with session.get(url + "&nd=1") as response:
page = await response.text()

soup = BeautifulSoup(page, 'html.parser')
Expand Down