YCast/ycast/generic.py
2019-08-19 13:57:35 +02:00

34 lines
844 B
Python

import logging
USER_AGENT = 'YCast'
class Directory:
def __init__(self, name, item_count):
self.name = name
self.item_count = item_count
def generate_stationid_with_prefix(uid, prefix):
if not prefix or len(prefix) != 2:
logging.error("Invalid station prefix length (must be 2)")
return None
if not uid:
logging.error("Missing station id for full station id generation")
return None
return str(prefix) + '_' + str(uid)
def get_stationid_prefix(uid):
if len(uid) < 4:
logging.error("Could not extract stationid (Invalid station id length)")
return None
return uid[:2]
def get_stationid_without_prefix(uid):
if len(uid) < 4:
logging.error("Could not extract stationid (Invalid station id length)")
return None
return uid[3:]