Skip to content

Instantly share code, notes, and snippets.

@PaNaVTEC
Last active December 7, 2015 12:37
Show Gist options
  • Save PaNaVTEC/99536cf4c46a053062b2 to your computer and use it in GitHub Desktop.
Save PaNaVTEC/99536cf4c46a053062b2 to your computer and use it in GitHub Desktop.
Converts "Los 40 principales" playlist to "Artist - Title" to use with playlist-converter.net for example and import to Deezer/Spotify
import requests
import re
import unicodedata
REGEX_LOS40 = "datos_cancion_\d+\['(titulo_cancion|nombre_artista)'\]\s*=\s*'([^\']*)'"
def removeAccents(data):
return unicodedata.normalize('NFKD', data).encode('ASCII', 'ignore').decode()
def sanitize(artist):
return re.sub(r'(?is)\(.+', '', artist)
response = requests.get(url="http://los40.com/lista40/?o=VL40")
regexFind = re.finditer(REGEX_LOS40, response.text)
i = 0
artist = ''
title = ''
for match in regexFind:
if i % 2 == 0:
title = match.group(2)
else:
artist = match.group(2)
print(artist + "-" + title)
title = ''
artist = ''
i += 1
@mathieue
Copy link

mathieue commented Dec 7, 2015

Hello. I am the creator of playlist converter.
First: thanks for the contribution.
Is it possible it take your code for a tutorial on playlist-converter.net ? take the code or reference this gist to be more precise..
Second: do you have any feature request for my tool as you are an advanced user.. coding... Any idea of an input better than free text ? what do you think about csv ?
Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment