cc-4329: Fixed this by adding liquid soap playability test from mm1
This commit is contained in:
parent
3eac8c8531
commit
434bcf15ab
2 changed files with 18 additions and 0 deletions
|
@ -161,6 +161,8 @@ class Metadata(Loggable):
|
||||||
# Forcing the unicode through
|
# Forcing the unicode through
|
||||||
try : fpath = fpath.decode("utf-8")
|
try : fpath = fpath.decode("utf-8")
|
||||||
except : pass
|
except : pass
|
||||||
|
if not mmp.file_playable(fpath):
|
||||||
|
raise BadSongFile(fpath)
|
||||||
try : full_mutagen = mutagen.File(fpath, easy=True)
|
try : full_mutagen = mutagen.File(fpath, easy=True)
|
||||||
except Exception : raise BadSongFile(fpath)
|
except Exception : raise BadSongFile(fpath)
|
||||||
self.path = fpath
|
self.path = fpath
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import copy
|
import copy
|
||||||
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import re
|
import re
|
||||||
|
@ -449,6 +450,21 @@ def owner_id(original_path):
|
||||||
except Exception: raise
|
except Exception: raise
|
||||||
return owner_id
|
return owner_id
|
||||||
|
|
||||||
|
def file_playable(pathname):
|
||||||
|
|
||||||
|
#when there is an single apostrophe inside of a string quoted by
|
||||||
|
#apostrophes, we can only escape it by replace that apostrophe with '\''.
|
||||||
|
#This breaks the string into two, and inserts an escaped single quote in
|
||||||
|
#between them. We run the command as pypo because otherwise the target file
|
||||||
|
#is opened with write permissions, and this causes an inotify ON_CLOSE_WRITE
|
||||||
|
#event to be fired :/
|
||||||
|
|
||||||
|
command = ("sudo -u pypo airtime-liquidsoap -c 'output.dummy" + \
|
||||||
|
"(audio_to_stereo(single(\"%s\")))' > /dev/null 2>&1") % \
|
||||||
|
pathname.replace("'", "'\\''")
|
||||||
|
return_code = subprocess.call(command, shell=True)
|
||||||
|
return (return_code == 0)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import doctest
|
import doctest
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue