|
@@ -24,8 +24,10 @@ import subprocess
|
|
|
|
|
|
from outputhelper import printf
|
|
from outputhelper import printf
|
|
|
|
|
|
|
|
+
|
|
class video(object):
|
|
class video(object):
|
|
- def __init__(self, title, description, ytid, conf, downloaded, failcount = 0, id=0):
|
|
|
|
|
|
+ def __init__(self, title, description, ytid, conf, downloaded, failcount=0,
|
|
|
|
+ id=0):
|
|
self.__ID = id
|
|
self.__ID = id
|
|
self.title = title
|
|
self.title = title
|
|
self.description = description
|
|
self.description = description
|
|
@@ -53,16 +55,16 @@ and can't be created. Please check your configuration and try again"),
|
|
printf(_('Downloading video "%s"' % self.title),
|
|
printf(_('Downloading video "%s"' % self.title),
|
|
outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
if self.__conf.outputlevel == "default":
|
|
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],
|
|
|
|
|
|
+ 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"))
|
|
stderr=sys.stderr, stdout=open("/dev/null", "w"))
|
|
elif self.__conf.outputlevel == "verbose":
|
|
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],
|
|
|
|
|
|
+ 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)
|
|
stderr=sys.stderr, stdout=sys.stdout)
|
|
elif self.__conf.outputlevel == "quiet":
|
|
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],
|
|
|
|
|
|
+ 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"))
|
|
stderr=open("/dev/null", "w"), stdout=open("/dev/null", "w"))
|
|
try:
|
|
try:
|
|
self.__database = sqlite3.connect(self.__conf.dbpath)
|
|
self.__database = sqlite3.connect(self.__conf.dbpath)
|
|
@@ -70,7 +72,8 @@ and can't be created. Please check your configuration and try again"),
|
|
printf(_("The Video \"%s\" has been "
|
|
printf(_("The Video \"%s\" has been "
|
|
"downloaded but the status could not be updated in the database. "
|
|
"downloaded but the status could not be updated in the database. "
|
|
"Please check what went wrong and correct it" % self.title),
|
|
"Please check what went wrong and correct it" % self.title),
|
|
- outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
|
|
|
|
+ outputlevel="default", level=self.__conf.outputlevel,
|
|
|
|
+ descriptor="stderr")
|
|
else:
|
|
else:
|
|
self.__cursor = self.__database.cursor()
|
|
self.__cursor = self.__database.cursor()
|
|
printf(_('Downloaded video "%s", updating database accordingly.'
|
|
printf(_('Downloaded video "%s", updating database accordingly.'
|
|
@@ -92,14 +95,15 @@ and can't be created. Please check your configuration and try again"),
|
|
printf(_("The Video \"%s\" has failed "
|
|
printf(_("The Video \"%s\" has failed "
|
|
"downloading but the status could not be updated in the database. "
|
|
"downloading but the status could not be updated in the database. "
|
|
"Please check what went wrong and correct it" % self.title),
|
|
"Please check what went wrong and correct it" % self.title),
|
|
- outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
|
|
|
|
+ outputlevel="default", level=self.__conf.outputlevel,
|
|
|
|
+ descriptor="stderr")
|
|
else:
|
|
else:
|
|
self.__cursor = self.__database.cursor()
|
|
self.__cursor = self.__database.cursor()
|
|
self.failcnt = int(self.failcnt) + 1
|
|
self.failcnt = int(self.failcnt) + 1
|
|
if self.failcnt >= int(self.__conf.values["maxfails"]):
|
|
if self.failcnt >= int(self.__conf.values["maxfails"]):
|
|
printf(_("The video \"%s\" has failed downloading too often, marking as"
|
|
printf(_("The video \"%s\" has failed downloading too often, marking as"
|
|
- " failed" % self.title), outputlevel="default", level=self.__conf.outputlevel,
|
|
|
|
- descriptor="stderr")
|
|
|
|
|
|
+ " failed" % self.title), outputlevel="default",
|
|
|
|
+ level=self.__conf.outputlevel, descriptor="stderr")
|
|
self.__statement = "UPDATE videos SET downloaded = -1 WHERE id = ?"
|
|
self.__statement = "UPDATE videos SET downloaded = -1 WHERE id = ?"
|
|
self.__cursor.execute(self.__statement, (self.__ID,))
|
|
self.__cursor.execute(self.__statement, (self.__ID,))
|
|
self.__statement = "UPDATE videos SET failcnt = ? WHERE id = ?"
|
|
self.__statement = "UPDATE videos SET failcnt = ? WHERE id = ?"
|
|
@@ -118,7 +122,7 @@ and can't be created. Please check your configuration and try again"),
|
|
self.__database = sqlite3.connect(self.__conf.dbpath)
|
|
self.__database = sqlite3.connect(self.__conf.dbpath)
|
|
except sqlite3.OperationalError:
|
|
except sqlite3.OperationalError:
|
|
printf(_("Could not connect to the database, please check settings and"
|
|
printf(_("Could not connect to the database, please check settings and"
|
|
- "permissions and try again"), outputlevel="default",
|
|
|
|
|
|
+ "permissions and try again"), outputlevel="default",
|
|
level=self.__conf.outputlevel, descriptor="stderr")
|
|
level=self.__conf.outputlevel, descriptor="stderr")
|
|
return False
|
|
return False
|
|
else:
|
|
else:
|