Skip to content

Instantly share code, notes, and snippets.

@Ray-Eldath
Created June 3, 2021 16:04
Show Gist options
  • Save Ray-Eldath/cee1dc64dab9b0a760d9aad8964d67a2 to your computer and use it in GitHub Desktop.
Save Ray-Eldath/cee1dc64dab9b0a760d9aad8964d67a2 to your computer and use it in GitHub Desktop.
netease-music likes exporter
import requests, json
def main():
r = requests.get('http://127.0.0.1:3000/likelist', params={'uid': 330793262, # your uid
'cookie': 'your cookie'})
r = json.loads(r.text)['ids']
total = len(r)
processed = 0
anomalies = []
file = open("music", "w")
print("processing...")
for x in range(0, len(r) // 10 + 1):
ids = ','.join([str(r[i]) for i in range(processed, len(r), 10)])
songs = requests.get('http://127.0.0.1:3000/song/detail', params={'ids': ids})
songs = json.loads(songs.text)['songs']
result = []
for song in songs:
if song['name'] is None:
anomalies.append(song)
continue
result.append(song['name'] + ' - ' + ', '.join([ar['name'] for ar in song['ar']]))
file.write('\n'.join(result))
processed += len(result)
print({'total': total, 'processed': processed, 'anomalies': anomalies})
file.flush()
file.close()
print('done.')
print({'total': total, 'processed': processed, 'anomalies': anomalies})
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment