Refactor override preference
Properly defaults the preference to be true and always return a boolean value since that is what celery will be expecting.
This commit is contained in:
parent
fefc53c000
commit
ae4c9203e6
|
@ -144,10 +144,6 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
$allowedCorsUrls->setValue($allowedCorsUrlsValue);
|
||||
$this->addElement($allowedCorsUrls);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$locale = new Zend_Form_Element_Select("locale");
|
||||
$locale->setLabel(_("Default Language"));
|
||||
$locale->setMultiOptions(Application_Model_Locale::getLocales());
|
||||
|
|
|
@ -358,8 +358,7 @@ class Application_Model_Preference
|
|||
{
|
||||
self::setValue("third_party_api", $bool);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function GetAllow3rdPartyApi()
|
||||
{
|
||||
$val = self::getValue("third_party_api");
|
||||
|
@ -374,11 +373,9 @@ class Application_Model_Preference
|
|||
public static function GetPodcastAlbumOverride()
|
||||
{
|
||||
$val = self::getValue("podcast_album_override");
|
||||
return (strlen($val) == 0 ) ? "1" : $val;
|
||||
return $val === '1' ? true : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function SetPhone($phone)
|
||||
{
|
||||
self::setValue("phone", $phone);
|
||||
|
|
|
@ -157,15 +157,10 @@ def podcast_download(id, url, callback_url, api_key, podcast_name, album_overrid
|
|||
# currently hardcoded for mp3s may want to add support for oggs etc
|
||||
m = MP3(audiofile.name, ID3=EasyID3)
|
||||
logger.debug('podcast_download loaded mp3 {0}'.format(audiofile.name))
|
||||
# replace the album id3 tag with the podcast name if the album tag is empty
|
||||
try:
|
||||
m['album']
|
||||
except KeyError:
|
||||
logger.debug('setting new album name to {0} in podcast'.format(podcast_name.encode('ascii', 'ignore')))
|
||||
m['album'] = podcast_name
|
||||
# if the album override option is enabled replace the album id3 tag with the podcast name even if the album tag contains data
|
||||
if album_override is True:
|
||||
m['album'] = podcast_name
|
||||
|
||||
# replace album title as needed
|
||||
m = podcast_override_album(m, podcast_name, album_override)
|
||||
|
||||
m.save()
|
||||
filetypeinfo = m.pprint()
|
||||
logger.info('filetypeinfo is {0}'.format(filetypeinfo.encode('ascii', 'ignore')))
|
||||
|
@ -181,6 +176,22 @@ def podcast_download(id, url, callback_url, api_key, podcast_name, album_overrid
|
|||
obj['status'] = 0
|
||||
return json.dumps(obj)
|
||||
|
||||
def podcast_override_album(m, podcast_name, override):
|
||||
"""
|
||||
Override m['album'] if empty or forced with override arg
|
||||
"""
|
||||
# if the album override option is enabled replace the album id3 tag with the podcast name even if the album tag contains data
|
||||
if override is True:
|
||||
logger.debug('overriding album name to {0} in podcast'.format(podcast_name.encode('ascii', 'ignore')))
|
||||
m['album'] = podcast_name
|
||||
else:
|
||||
# replace the album id3 tag with the podcast name if the album tag is empty
|
||||
try:
|
||||
m['album']
|
||||
except KeyError:
|
||||
logger.debug('setting new album name to {0} in podcast'.format(podcast_name.encode('ascii', 'ignore')))
|
||||
m['album'] = podcast_name
|
||||
return m
|
||||
|
||||
def get_filename(r):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue