Created
June 20, 2022 03:57
-
-
Save Slyyxp/b2a07a2756a5416bac4e9d03f85723ae to your computer and use it in GitHub Desktop.
Revisions
-
Slyyxp renamed this gist
Jun 20, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Slyyxp created this gist
Jun 20, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ import requests # epoints # https://play.melon.com/cds/delivery/android/streaming_path.json class Client: def __init__(self): self.session = requests.Session() self.session.headers.update({ "User-Agent": "Mozilla/5.0 (Linux; Android 5.1.1; SM-G973N Build/PPR1.190810.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36", }) resp = self.auth() resp = self.prestream(34614815) print(resp) def make_call(self, sub, epoint, data): r = self.session.post( "https://{}.melon.com/{}".format(sub, epoint), data=data) r.raise_for_status() return r def auth(self): data = { "client_id": "5c2982b2ec377339ee67d3686f4813ac", "app_key": "5c2982b2ec377339ee67d3686f4813ac", "email": "", "password": ""} r = self.session.post( "https://auth.kakao.com/kakao_accounts/login.json", data=data ) r.raise_for_status() return r.json() def streaming_path(self, id): data = { "cpId": "", "cpKey": "", "v": "4.0", "resolution": "2", "appVer": "6.4.1", "cType": 1, "cId": id, "metaType": "", "bitrate": "", "sessionId": "", "networkType": "wifi" } r = self.make_call("app", "cds/delivery/android/streaming_path.json", data) return r def prestream(self, id): data = { "q": "", "cid": id, "cacheEnable": "Y", "isLocal": "N", "bitrate": "96", "metaType": "AAC" } file_path = "test.mp4" r = self.session.post("https://spmd.melon.com/prestream", data=data) with open(file_path, 'wb') as f: for chunk in r.iter_content(32 * 1024): if chunk: f.write(chunk) return r