diff options
Diffstat (limited to 'module/plugins/hoster')
| -rw-r--r-- | module/plugins/hoster/YoutubeCom.py | 23 | 
1 files changed, 22 insertions, 1 deletions
| diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 9f21ddf79..4bc608b05 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -4,11 +4,32 @@  import re  import subprocess  import os +import os.path  from urllib import unquote -from module.utils import html_unescape, which +from module.utils import html_unescape  from module.plugins.Hoster import Hoster +def which(program): +    """Works exactly like the unix command which + +    Courtesy of http://stackoverflow.com/a/377028/675646""" +    def is_exe(fpath): +        return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + +    fpath, fname = os.path.split(program) +    if fpath: +        if is_exe(program): +            return program +    else: +        for path in os.environ["PATH"].split(os.pathsep): +            path = path.strip('"') +            exe_file = os.path.join(path, program) +            if is_exe(exe_file): +                return exe_file + +    return None +  class YoutubeCom(Hoster):      __name__ = "YoutubeCom"      __type__ = "hoster" | 
