|
@@ -44,10 +44,11 @@ class conf(object):
|
|
|
"password": "",
|
|
|
"youtube-dl": "",
|
|
|
"notify": "yes",
|
|
|
- "config_version": "5",
|
|
|
- "db_version": "1",
|
|
|
+ "config_version": "6",
|
|
|
+ "db_version": "2",
|
|
|
"videocodec": "h264",
|
|
|
- "maxresolution": "1080p"
|
|
|
+ "maxresolution": "1080p",
|
|
|
+ "maxfails": "50"
|
|
|
}
|
|
|
self.dbpath = str(os.environ['HOME']) + "/.stov/" + self.values["database"]
|
|
|
self.outputlevel = "default"
|
|
@@ -101,7 +102,8 @@ class conf(object):
|
|
|
description TEXT,
|
|
|
ytid TEXT,
|
|
|
subscription_id INTEGER,
|
|
|
- downloaded int
|
|
|
+ downloaded INT,
|
|
|
+ failcnt INT DEFAULT 0
|
|
|
);""")
|
|
|
self.__database.commit()
|
|
|
self.__database.close()
|
|
@@ -162,6 +164,7 @@ class conf(object):
|
|
|
printf(_("Invalid config version read"), outputlevel="default",
|
|
|
level=self.outputlevel, descriptor="stderr")
|
|
|
self.values["config_version"] = "0"
|
|
|
+ self.__currentdbversion = self.values["db_version"]
|
|
|
self.ReadConfig()
|
|
|
printf(_("Found running version: " + self.values["config_version"] + "\n" +
|
|
|
"Current version: " + str(self.__currentversion)),
|
|
@@ -185,18 +188,13 @@ class conf(object):
|
|
|
"""Checks the database if it is up-to-date"""
|
|
|
printf(_("Checking current and running database version."),
|
|
|
outputlevel="verbose", level=self.outputlevel, descriptor="stderr")
|
|
|
- try:
|
|
|
- self.__currentversion = int(self.values["db_version"])
|
|
|
- except ValueError:
|
|
|
- printf(_("Invalid config version read"), outputlevel="default",
|
|
|
- level=self.outputlevel, descriptor="stderr")
|
|
|
self.values["db_version"] = "0"
|
|
|
self.ReadConfig()
|
|
|
printf(_("Found running database version: " + self.values["db_version"] +
|
|
|
"\n" + "Current version: " + str(self.__currentversion)),
|
|
|
outputlevel="verbose", level=self.outputlevel, descriptor="stderr")
|
|
|
- if self.values["db_version"] == "0" \
|
|
|
- or int(self.values["db_version"]) < self.__currentversion:
|
|
|
+ if self.values["db_version"] == "0" or \
|
|
|
+ int(self.values["db_version"]) < int(self.__currentdbversion):
|
|
|
self.values["db_version"] = str(self.__currentversion)
|
|
|
return False
|
|
|
else:
|
|
@@ -205,7 +203,23 @@ class conf(object):
|
|
|
|
|
|
def UpdateDB(self):
|
|
|
"""Performs database changes that need to be done"""
|
|
|
+ self.ReadConfig()
|
|
|
if int(self.values["db_version"]) == 1:
|
|
|
+ try:
|
|
|
+ self.__database = sqlite3.connect(self.dbpath)
|
|
|
+ except sqlite3.OperationalError:
|
|
|
+ printf(_("The database could not be updated, please "
|
|
|
+ "check that the configuration directory exists and is writable"),
|
|
|
+ outputlevel = "default", level=self.outputlevel, descriptor="stderr")
|
|
|
+ else:
|
|
|
+ self.__dbcursor = self.__database.cursor()
|
|
|
+ self.__dbcursor.execute("ALTER TABLE videos add column failcnt int DEFAULT 0;")
|
|
|
+ self.__database.commit()
|
|
|
+ self.__database.close()
|
|
|
+ self.ReadConfig()
|
|
|
+ self.values["db_version"] = "2"
|
|
|
+ self.WriteConfig()
|
|
|
+ else:
|
|
|
pass
|
|
|
|
|
|
def GetYoutubeParameter(self):
|