Unify version and user agent

Also use more detailed user agent as proposed by the Radiobrowser API
This commit is contained in:
milaq 2019-08-18 14:11:38 +02:00
parent 895a5aa37f
commit 333fc2012f
4 changed files with 10 additions and 3 deletions

View file

@ -1,11 +1,13 @@
from setuptools import setup, find_packages
import ycast
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name='ycast',
version='0.9.8',
version=ycast.__version__,
author='Micha LaQua',
author_email='micha.laqua@gmail.com',
description='Self hosted vTuner internet radio service emulation',

View file

@ -4,6 +4,7 @@ import argparse
import logging
import sys
from ycast import __version__
from ycast import server
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=logging.INFO)
@ -16,10 +17,10 @@ def launch_server():
parser.add_argument('-p', action='store', dest='port', type=int, help='Listen port', default=80)
parser.add_argument('-d', action='store_true', dest='debug', help='Enable debug logging')
arguments = parser.parse_args()
logging.info("YCast (%s) server starting", __version__)
if arguments.debug:
logging.getLogger().setLevel(logging.DEBUG)
logging.debug("Debug logging enabled")
logging.info("YCast server starting on %s:%s" % (arguments.address, arguments.port))
server.run(arguments.config, arguments.address, arguments.port)

View file

@ -1,3 +1,6 @@
USER_AGENT = 'YCast'
class Directory:
def __init__(self, name, item_count):
self.name = name

View file

@ -1,6 +1,7 @@
import requests
import logging
from ycast import __version__
import ycast.vtuner as vtuner
import ycast.generic as generic
@ -38,7 +39,7 @@ class Station:
def request(url):
logging.debug("Radiobrowser API request: %s", url)
headers = {'content-type': 'application/json', 'User-Agent': 'YCast'}
headers = {'content-type': 'application/json', 'User-Agent': generic.USER_AGENT + '/' + __version__}
response = requests.get('http://www.radio-browser.info/webservice/json/' + url, headers=headers)
if response.status_code != 200:
logging.error("Could not fetch data from Radiobrowser (%s)", response.status_code)