|
@@ -27,7 +27,7 @@ from lib_stov import stov_exceptions
|
|
|
|
|
|
class video(object):
|
|
|
def __init__(self, title, description, ytid, conf, downloaded, failcount=0,
|
|
|
- id=0):
|
|
|
+ id=0):
|
|
|
self.__ID = id
|
|
|
self.title = title
|
|
|
self.description = description
|
|
@@ -38,28 +38,36 @@ class video(object):
|
|
|
|
|
|
def DownloadVideo(self, directory, itag_value):
|
|
|
"""Downloads the video by calling youtube-dl as an external process"""
|
|
|
- self.__targetdir = self.__conf.values["downloaddir"] + "/" + directory
|
|
|
- if os.access(self.__targetdir, os.F_OK) is False:
|
|
|
+ targetdir = self.__conf.values["downloaddir"] + "/" + directory
|
|
|
+ if os.access(targetdir, os.F_OK) is False:
|
|
|
try:
|
|
|
- os.makedirs(self.__targetdir, 0o750)
|
|
|
+ os.makedirs(targetdir, 0o750)
|
|
|
except os.error:
|
|
|
raise stov_exceptions.DirectoryCreationFailedException()
|
|
|
|
|
|
- os.chdir(self.__targetdir)
|
|
|
+ os.chdir(targetdir)
|
|
|
if self.downloaded == 0:
|
|
|
try:
|
|
|
if self.__conf.outputlevel == "default":
|
|
|
subprocess.check_call(["youtube-dl", "--max-quality=%s"
|
|
|
- % itag_value, "-t", "http://www.youtube.com/watch?v=%s" % self.ytid],
|
|
|
- stderr=sys.stderr, stdout=open("/dev/null", "w"))
|
|
|
+ % itag_value, "-t",
|
|
|
+ "http://www.youtube.com/watch?v=%s"
|
|
|
+ % self.ytid],
|
|
|
+ stderr=sys.stderr,
|
|
|
+ stdout=open("/dev/null", "w"))
|
|
|
elif self.__conf.outputlevel == "verbose":
|
|
|
subprocess.check_call(["youtube-dl", "--max-quality=%s"
|
|
|
- % itag_value, "-t", "http://www.youtube.com/watch?v=%s" % self.ytid],
|
|
|
- stderr=sys.stderr, stdout=sys.stdout)
|
|
|
+ % itag_value, "-t",
|
|
|
+ "http://www.youtube.com/watch?v=%s"
|
|
|
+ % self.ytid],
|
|
|
+ stderr=sys.stderr, stdout=sys.stdout)
|
|
|
elif self.__conf.outputlevel == "quiet":
|
|
|
subprocess.check_call(["youtube-dl", "--max-quality=%s"
|
|
|
- % itag_value, "-t", "http://www.youtube.com/watch?v=%s" % self.ytid],
|
|
|
- stderr=open("/dev/null", "w"), stdout=open("/dev/null", "w"))
|
|
|
+ % itag_value, "-t",
|
|
|
+ "http://www.youtube.com/watch?v=%s"
|
|
|
+ % self.ytid],
|
|
|
+ stderr=open("/dev/null", "w"),
|
|
|
+ stdout=open("/dev/null", "w"))
|
|
|
except subprocess.CalledProcessError:
|
|
|
self.failcnt = int(self.failcnt) + 1
|
|
|
return False
|
|
@@ -71,4 +79,4 @@ class video(object):
|
|
|
self.__ID = id
|
|
|
|
|
|
def GetID(self):
|
|
|
- return self.__ID
|
|
|
+ return self.__ID
|