Add dynamic directory displayname

Also capitalize genres and all capitalize languages

Co-authored-by: Jonathan Rawle <git@jonathanrawle.co.uk>
This commit is contained in:
milaq 2020-10-10 16:36:44 +02:00
parent ab2ac64cc0
commit f39b65e759
3 changed files with 11 additions and 4 deletions

View file

@ -7,9 +7,13 @@ CACHE_PATH = VAR_PATH + '/cache'
class Directory:
def __init__(self, name, item_count):
def __init__(self, name, item_count, displayname=None):
self.name = name
self.item_count = item_count
if displayname:
self.displayname = displayname
else:
self.displayname = name
def generate_stationid_with_prefix(uid, prefix):

View file

@ -101,7 +101,8 @@ def get_language_directories():
if get_json_attr(language_raw, 'name') and get_json_attr(language_raw, 'stationcount') and \
int(get_json_attr(language_raw, 'stationcount')) > MINIMUM_COUNT_LANGUAGE:
language_directories.append(generic.Directory(get_json_attr(language_raw, 'name'),
get_json_attr(language_raw, 'stationcount')))
get_json_attr(language_raw, 'stationcount'),
get_json_attr(language_raw, 'name').title()))
return language_directories
@ -115,7 +116,8 @@ def get_genre_directories():
if get_json_attr(genre_raw, 'name') and get_json_attr(genre_raw, 'stationcount') and \
int(get_json_attr(genre_raw, 'stationcount')) > MINIMUM_COUNT_GENRE:
genre_directories.append(generic.Directory(get_json_attr(genre_raw, 'name'),
get_json_attr(genre_raw, 'stationcount')))
get_json_attr(genre_raw, 'stationcount'),
get_json_attr(genre_raw, 'name').capitalize()))
return genre_directories

View file

@ -47,7 +47,8 @@ def get_directories_page(subdir, directories, request):
page.set_count(1)
return page
for directory in get_paged_elements(directories, request.args):
vtuner_directory = vtuner.Directory(directory.name, url_for(subdir, _external=True, directory=directory.name),
vtuner_directory = vtuner.Directory(directory.displayname,
url_for(subdir, _external=True, directory=directory.name),
directory.item_count)
page.add(vtuner_directory)
page.set_count(len(directories))