Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Last active October 4, 2019 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/732d97f1c70612b948e39306a9b1e999 to your computer and use it in GitHub Desktop.
Save jasongorman/732d97f1c70612b948e39306a9b1e999 to your computer and use it in GitHub Desktop.
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