mirror of
https://github.com/Findus23/RadioStats.git
synced 2024-09-19 16:03:48 +02:00
update arabella parser
This commit is contained in:
parent
b098de392e
commit
185cdc129e
3 changed files with 38 additions and 28 deletions
|
@ -1,17 +1,27 @@
|
|||
import json
|
||||
|
||||
from websocket import create_connection
|
||||
|
||||
from parser import BaseFetcher
|
||||
from utils import *
|
||||
|
||||
URL = "http://www.arabella.at/live-feed/ajax.php?station=zenon-rp-wien"
|
||||
URL = "wss://www.arabella.at/api/_socket/"
|
||||
|
||||
|
||||
class ArabellaFetcher(BaseFetcher):
|
||||
def get(self, channel):
|
||||
response = fetch(URL, True)
|
||||
if response:
|
||||
for track in response["songs"]:
|
||||
artist = track["artist"]
|
||||
title = track["title"]
|
||||
dt = track["start_date_time"]
|
||||
time = datetime(year=int(dt["year"]), month=int(dt["month"]), day=int(dt["day"]),
|
||||
hour=int(dt["hours"]), minute=int(dt["minutes"]), second=int(dt["seconds"]))
|
||||
yield time, artist, title
|
||||
ws = create_connection(URL, suppress_origin=True)
|
||||
init = ws.recv()
|
||||
|
||||
ws.send(json.dumps({"type": "select_channels", "channelIds": [1]}))
|
||||
|
||||
result = ws.recv()
|
||||
data = json.loads(result)
|
||||
tracks = [data["currentTrack"]]
|
||||
tracks.extend(data["previousTracks"])
|
||||
tracks.extend(data["futureTracks"])
|
||||
for track in tracks:
|
||||
artist = track["artist"]
|
||||
title = track["title"]
|
||||
time = time_to_date(string_to_time(track["time"], seconds=False))
|
||||
yield time, artist, title
|
||||
|
|
34
poetry.lock
generated
34
poetry.lock
generated
|
@ -156,18 +156,6 @@ category = "main"
|
|||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[[package]]
|
||||
name = "pymysql"
|
||||
version = "1.0.2"
|
||||
description = "Pure Python MySQL Driver"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.extras]
|
||||
ed25519 = ["PyNaCl (>=1.4.0)"]
|
||||
rsa = ["cryptography"]
|
||||
|
||||
[[package]]
|
||||
name = "pytz"
|
||||
version = "2021.3"
|
||||
|
@ -281,6 +269,18 @@ brotli = ["brotlipy (>=0.6.0)"]
|
|||
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
|
||||
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "websocket-client"
|
||||
version = "1.2.1"
|
||||
description = "WebSocket client for Python with low level API options"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.extras]
|
||||
optional = ["python-socks", "wsaccel"]
|
||||
test = ["websockets"]
|
||||
|
||||
[[package]]
|
||||
name = "werkzeug"
|
||||
version = "2.0.2"
|
||||
|
@ -295,7 +295,7 @@ watchdog = ["watchdog"]
|
|||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = ">=3.8,<4"
|
||||
content-hash = "7590ee0d4b1ba2d4f2d07f67ab3ac29dbf103087daea994e9887b5fc1261e51a"
|
||||
content-hash = "72cae7774c43104bf5a4130b2e0b99210bdb4d8217c3c71d4a3607dc96f0f740"
|
||||
|
||||
[metadata.files]
|
||||
beautifulsoup4 = [
|
||||
|
@ -396,10 +396,6 @@ psycopg2 = [
|
|||
{file = "psycopg2-2.9.2-cp39-cp39-win_amd64.whl", hash = "sha256:fd7ddab7d6afee4e21c03c648c8b667b197104713e57ec404d5b74097af21e31"},
|
||||
{file = "psycopg2-2.9.2.tar.gz", hash = "sha256:a84da9fa891848e0270e8e04dcca073bc9046441eeb47069f5c0e36783debbea"},
|
||||
]
|
||||
pymysql = [
|
||||
{file = "PyMySQL-1.0.2-py3-none-any.whl", hash = "sha256:41fc3a0c5013d5f039639442321185532e3e2c8924687abe6537de157d403641"},
|
||||
{file = "PyMySQL-1.0.2.tar.gz", hash = "sha256:816927a350f38d56072aeca5dfb10221fe1dc653745853d30a216637f5d7ad36"},
|
||||
]
|
||||
pytz = [
|
||||
{file = "pytz-2021.3-py2.py3-none-any.whl", hash = "sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c"},
|
||||
{file = "pytz-2021.3.tar.gz", hash = "sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326"},
|
||||
|
@ -433,6 +429,10 @@ urllib3 = [
|
|||
{file = "urllib3-1.26.7-py2.py3-none-any.whl", hash = "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"},
|
||||
{file = "urllib3-1.26.7.tar.gz", hash = "sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece"},
|
||||
]
|
||||
websocket-client = [
|
||||
{file = "websocket-client-1.2.1.tar.gz", hash = "sha256:8dfb715d8a992f5712fff8c843adae94e22b22a99b2c5e6b0ec4a1a981cc4e0d"},
|
||||
{file = "websocket_client-1.2.1-py2.py3-none-any.whl", hash = "sha256:0133d2f784858e59959ce82ddac316634229da55b498aac311f1620567a710ec"},
|
||||
]
|
||||
werkzeug = [
|
||||
{file = "Werkzeug-2.0.2-py3-none-any.whl", hash = "sha256:63d3dc1cf60e7b7e35e97fa9861f7397283b75d765afcaefd993d6046899de8f"},
|
||||
{file = "Werkzeug-2.0.2.tar.gz", hash = "sha256:aa2bb6fc8dee8d6c504c0ac1e7f5f7dc5810a9903e793b6f715a9f015bdadb9a"},
|
||||
|
|
|
@ -13,11 +13,11 @@ sentry-sdk = {extras = ["flask"], version = "^1.1.0"}
|
|||
spotipy = "2.16.0"
|
||||
peewee = "^3.13.1"
|
||||
beautifulsoup4 = "^4.8.2"
|
||||
PyMySQL = "^1.0.2"
|
||||
pytz = "^2021.1"
|
||||
gunicorn = "^20.0.4"
|
||||
redis = "^3.3.11"
|
||||
psycopg2 = "^2.9.2"
|
||||
websocket-client = "^1.2.1"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
|
|
Loading…
Reference in a new issue