feat: Load language file in lang/ instead of the ini file.
This commit is contained in:
14
media/url.py
14
media/url.py
@ -9,7 +9,7 @@ import glob
|
||||
from io import BytesIO
|
||||
import base64
|
||||
|
||||
import constants
|
||||
from constants import tr_cli as tr
|
||||
import media
|
||||
import variables as var
|
||||
from media.item import BaseItem, item_builders, item_loaders, item_id_generators, ValidationFailedError, \
|
||||
@ -99,7 +99,7 @@ class URLItem(BaseItem):
|
||||
# Check the length, useful in case of playlist, it wasn't checked before)
|
||||
log.info(
|
||||
"url: " + self.url + " has a duration of " + str(self.duration / 60) + " min -- too long")
|
||||
raise ValidationFailedError(constants.tr('too_long', song=self.title))
|
||||
raise ValidationFailedError(tr('too_long', song=self.title))
|
||||
else:
|
||||
self.ready = "validated"
|
||||
self.version += 1 # notify wrapper to save me
|
||||
@ -138,7 +138,7 @@ class URLItem(BaseItem):
|
||||
if not succeed:
|
||||
self.ready = 'failed'
|
||||
self.log.error("url: error while fetching info from the URL")
|
||||
raise ValidationFailedError(constants.tr('unable_download', item=self.format_title()))
|
||||
raise ValidationFailedError(tr('unable_download', item=self.format_title()))
|
||||
|
||||
def _download(self):
|
||||
media.system.clear_tmp_folder(var.tmp_folder, var.config.getint('bot', 'tmp_folder_max_size'))
|
||||
@ -193,7 +193,7 @@ class URLItem(BaseItem):
|
||||
os.remove(f)
|
||||
self.ready = "failed"
|
||||
self.downloading = False
|
||||
raise PreparationFailedError(constants.tr('unable_download', item=self.format_title()))
|
||||
raise PreparationFailedError(tr('unable_download', item=self.format_title()))
|
||||
|
||||
def _read_thumbnail_from_file(self, path_thumbnail):
|
||||
if os.path.isfile(path_thumbnail):
|
||||
@ -226,14 +226,14 @@ class URLItem(BaseItem):
|
||||
|
||||
def format_song_string(self, user):
|
||||
if self.ready in ['validated', 'yes']:
|
||||
return constants.tr("url_item",
|
||||
return tr("url_item",
|
||||
title=self.title if self.title else "??",
|
||||
url=self.url,
|
||||
user=user)
|
||||
return self.url
|
||||
|
||||
def format_current_playing(self, user):
|
||||
display = constants.tr("now_playing", item=self.format_song_string(user))
|
||||
display = tr("now_playing", item=self.format_song_string(user))
|
||||
|
||||
if self.thumbnail:
|
||||
thumbnail_html = '<img width="80" src="data:image/jpge;base64,' + \
|
||||
@ -246,4 +246,4 @@ class URLItem(BaseItem):
|
||||
return self.title if self.title.strip() else self.url
|
||||
|
||||
def display_type(self):
|
||||
return constants.tr("url")
|
||||
return tr("url")
|
||||
|
Reference in New Issue
Block a user