-
-
Save jasongorman/732d97f1c70612b948e39306a9b1e999 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 json | |
from datetime import date | |
import requests | |
class DailySongSales(object): | |
def __init__(self, all_sales): | |
self.all_sales = all_sales | |
def sales_of(self, song): | |
song_sales = len(list(filter(lambda sale: sale.song == song, self.all_sales))) | |
# send to charts | |
url = "http://songchartscompiler.co.uk/senddailysales" | |
data = {'outlet': 'JG Digital Downloads inc', | |
'date': date.today().strftime('%d/%m/%Y'), | |
'song': song, | |
'sales': song_sales} | |
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} | |
requests.post(url, data=json.dumps(data), headers=headers) | |
return song_sales |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment