Unify version and user agent
Also use more detailed user agent as proposed by the Radiobrowser API
This commit is contained in:
parent
895a5aa37f
commit
333fc2012f
4 changed files with 10 additions and 3 deletions
4
setup.py
4
setup.py
|
@ -1,11 +1,13 @@
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
import ycast
|
||||||
|
|
||||||
with open("README.md", "r") as fh:
|
with open("README.md", "r") as fh:
|
||||||
long_description = fh.read()
|
long_description = fh.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='ycast',
|
name='ycast',
|
||||||
version='0.9.8',
|
version=ycast.__version__,
|
||||||
author='Micha LaQua',
|
author='Micha LaQua',
|
||||||
author_email='micha.laqua@gmail.com',
|
author_email='micha.laqua@gmail.com',
|
||||||
description='Self hosted vTuner internet radio service emulation',
|
description='Self hosted vTuner internet radio service emulation',
|
||||||
|
|
|
@ -4,6 +4,7 @@ import argparse
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from ycast import __version__
|
||||||
from ycast import server
|
from ycast import server
|
||||||
|
|
||||||
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=logging.INFO)
|
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('-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')
|
parser.add_argument('-d', action='store_true', dest='debug', help='Enable debug logging')
|
||||||
arguments = parser.parse_args()
|
arguments = parser.parse_args()
|
||||||
|
logging.info("YCast (%s) server starting", __version__)
|
||||||
if arguments.debug:
|
if arguments.debug:
|
||||||
logging.getLogger().setLevel(logging.DEBUG)
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
logging.debug("Debug logging enabled")
|
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)
|
server.run(arguments.config, arguments.address, arguments.port)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
USER_AGENT = 'YCast'
|
||||||
|
|
||||||
|
|
||||||
class Directory:
|
class Directory:
|
||||||
def __init__(self, name, item_count):
|
def __init__(self, name, item_count):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from ycast import __version__
|
||||||
import ycast.vtuner as vtuner
|
import ycast.vtuner as vtuner
|
||||||
import ycast.generic as generic
|
import ycast.generic as generic
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ class Station:
|
||||||
|
|
||||||
def request(url):
|
def request(url):
|
||||||
logging.debug("Radiobrowser API request: %s", 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)
|
response = requests.get('http://www.radio-browser.info/webservice/json/' + url, headers=headers)
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
logging.error("Could not fetch data from Radiobrowser (%s)", response.status_code)
|
logging.error("Could not fetch data from Radiobrowser (%s)", response.status_code)
|
||||||
|
|
Loading…
Reference in a new issue