Created
March 16, 2017 15:25
-
-
Save paramsingh/1fdf0d1ac0da8cae972c1ff4408701b0 to your computer and use it in GitHub Desktop.
This file contains 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 characters
import requests | |
import json | |
url = 'http://0.0.0.0:3031/1/user/iliekcomputers/listens' | |
server = 'http://listenbrainz.org/1/user/iliekcomputers/listens' | |
r = requests.get(url, params = {'count': 2}) | |
print json.dumps(json.loads(r.text), indent = 4) | |
""" | |
r = requests.get(server, params = {'count': 5}) | |
print json.dumps(json.loads(r.text), indent = 4) | |
""" |
This file contains 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 characters
from __future__ import print_function | |
import requests | |
import json | |
import time | |
import sys | |
USER_TOKEN = "Token YOUR_TOKEN_HERE" | |
url = 'http://0.0.0.0:3031/1/submit-listens' | |
data = { | |
"payload": [ | |
{ | |
"listened_at": 1489671410, | |
"track_metadata": { | |
"release_name": "Majid Jordan", | |
"track_name": "Every Step Every Way", | |
"artist_name": "Majid Jordan", | |
"additional_info": { | |
"genius_link": "https://genius.com/Majid-jordan-every-step-every-way-lyrics", | |
"best_song": "definitely", | |
"lastfm_link": "https://www.last.fm/music/Majid+Jordan/_/Every+Step+Every+Way", | |
"other_stuff": "teststuffplsignore" | |
} | |
} | |
} | |
], | |
"listen_type": "import", | |
} | |
data2 = { | |
'listen_type': 'single', | |
'payload': [ | |
{ | |
'track_metadata': { | |
'artist_name': 'Kanye West', | |
'track_name': 'Fade', | |
'release_name': 'The Life of Pablo', | |
} | |
}, | |
], | |
} | |
data3 = { | |
'listen_type': 'import', | |
'payload': [ | |
{ | |
'track_metadata': { | |
'artist_name': 'Kanye West', | |
'track_name': 'Fade', | |
'release_name': 'The Life of Pablo', | |
} | |
}, | |
{ | |
'track_metadata': { | |
'artist_name': "test", | |
'track_name': 'Fade', | |
} | |
} | |
], | |
} | |
def send(payload): | |
r = requests.post(url, headers = {"Authorization": USER_TOKEN}, data = json.dumps(payload)) | |
if r.status_code != 200: | |
print("error") | |
print(r.text) | |
else: | |
print("sent") | |
if __name__ == '__main__': | |
""" | |
data2['payload'][0]['listened_at'] = int(time.time()) | |
send(data2)""" | |
data['payload'][0]['listened_at'] = int(time.time()) | |
send(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment