-
-
Save breyten/1f7c75609dca06aa8cae to your computer and use it in GitHub Desktop.
Get ad spots based on broadcast
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
#!/usr/bin/env python | |
import os | |
import sys | |
import re | |
from pprint import pprint | |
import json | |
import MySQLdb | |
import requests | |
def get_spots(channel, db): | |
channelid = "RAD 1" | |
starttime = channel['startdatetime'].replace('T', ' ').replace('+01:00', '') | |
stoptime = channel['stopdatetime'].replace('T', ' ').replace('+01:00', '') | |
cursor = db.cursor() | |
r = cursor.execute( | |
"""SELECT * FROM `spots` WHERE channelid = %s AND broadcasttime >= %s AND broadcasttime <= %s""", | |
(channelid, | |
starttime, | |
stoptime,) | |
) | |
return cursor.fetchall() | |
if __name__ == '__main__': | |
db = MySQLdb.connect(user="spots", passwd="spots", db="sterspot") | |
channel = requests.get('http://radiobox2.omroep.nl/broadcast/rest/195969.json').json() | |
pprint(get_spots(channel, db)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment