1
0
Fork 0
mirror of https://github.com/Findus23/RadioStats.git synced 2024-09-19 16:03:48 +02:00
RadioStats/parser/eng.py
Lukas Winkler d286059289
major overhaul
- use new ORF API
- better structured fetchers
- easier channel metadata
2020-09-28 18:31:57 +02:00

22 lines
920 B
Python

from bs4 import BeautifulSoup
from parser import BaseFetcher
from utils import *
class EnergyFetcher(BaseFetcher):
disabled = True
def get(self, channel):
url = "http://www.energy.at/extern/tifo/?station=vie&hour={hour}&min={min}&date={date}&submit=1"
now = datetime.now() - timedelta(minutes=30)
url = url.format(hour=now.hour, min=now.minute, date=now.strftime("%d.%m.%Y"))
soup = BeautifulSoup(fetch(url, False), 'html.parser')
print(url)
for item in soup.findAll("div", "item"):
artist = item.find("p", "interpret").get_text()
title = item.find("p", "title").get_text()
timestring = item.find("span", "time").get_text()
datestring = item.find("span", "date").get_text()
time = local_to_utc(datetime.strptime(datestring + " " + timestring, '%d.%m.%Y %H:%M'))
yield time, artist, title