Skip to content

Instantly share code, notes, and snippets.

@tushalien
Last active April 21, 2020 08:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tushalien/96ae0743487468a978d476ec1c52a96c to your computer and use it in GitHub Desktop.
Save tushalien/96ae0743487468a978d476ec1c52a96c to your computer and use it in GitHub Desktop.
def fetch_srt(song_name,video_id):
#preparing the first parameter
res = 'A'.join(str(ord(c)+13) for c in video_id)
res = res+"A"
#fake request to get the current cookie
opener = urllib2.build_opener()
session = requests.session()
url="https://extension.musixmatch.com"
response = session.get(url,verify=False)
cookie_value = session.cookies.get_dict()
#HTTP request with http header values
opener.addheaders.append(('Host', "extension.musixmatch.com"))
opener.addheaders.append(('Cookie', cookie_value))
opener.addheaders.append(('User-agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36'))
url = "https://extension.musixmatch.com/?res="+res+"&hl=en-US&v="+video_id+"&type=track&lang=en&name&kind&fmt=1"
f = opener.open("https://extension.musixmatch.com/?res="+res+"&hl=en-US&v="+video_id+"&type=track&lang=en&name&kind&fmt=1")
f=f.read()
return f
@xmha97
Copy link

xmha97 commented Apr 21, 2020

Does it still work?

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