|
@@ -93,6 +93,8 @@ class MyOptionParser(OptionParser):
|
|
|
version: Print version number
|
|
|
quiet: Suppress all output
|
|
|
verbose: Print normal output + diagnostical messages
|
|
|
+ clean-database: Clean the database of old entries, meaning videos that
|
|
|
+ are no longer present in the current API response of youtube
|
|
|
"""
|
|
|
|
|
|
parser = MyOptionParser(usage=_("Usage: %prog [options]"), prog="stov",
|
|
@@ -129,6 +131,9 @@ parser.add_option("-q", "--quiet", dest="quiet", action="store_true",
|
|
|
help=_("Suppress all output"))
|
|
|
parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
|
|
|
help=_("Be verbose and print also diagnostical messages"))
|
|
|
+parser.add_option("-c", "--clean-database", dest="cleanup",
|
|
|
+action="store_true", help=_("Clean the database of entries no longer listed "
|
|
|
+"in the current API response"))
|
|
|
(options, arguments) = parser.parse_args()
|
|
|
|
|
|
"""Check if stov is run directly from command line since it shouldn't be
|
|
@@ -422,8 +427,9 @@ FROM subscriptions")
|
|
|
level=conf.outputlevel, descriptor="stderr")
|
|
|
serverconnection.quit()
|
|
|
elif videosdownloaded == 0 and videosfailed == 0:
|
|
|
- printf(_("No videos to be downloaded."), outputlevel="default",
|
|
|
- level=conf.outputlevel, descriptor="stdout")
|
|
|
+ if conf.values["notify"] == "no":
|
|
|
+ printf(_("No videos to be downloaded."), outputlevel="default",
|
|
|
+ level=conf.outputlevel, descriptor="stdout")
|
|
|
elif conf.values["notify"] == "no":
|
|
|
if videosfailed == 0:
|
|
|
printf(_("The following videos have been downloaded:\n"),
|
|
@@ -482,6 +488,37 @@ elif options.catchup is not None:
|
|
|
outputlevel="default", level=conf.outputlevel, descriptor="stderr")
|
|
|
|
|
|
|
|
|
+elif options.cleanup is True:
|
|
|
+ subscriptions_list = []
|
|
|
+ try:
|
|
|
+ database = sqlite3.connect(conf.dbpath)
|
|
|
+ cursor = database.cursor()
|
|
|
+ except sqlite3.OperationalError:
|
|
|
+ printf(_("Could not access the database, please check path and "
|
|
|
+ "permissions and try again!"), outputlevel="default",
|
|
|
+ level=conf.outputlevel, descriptor="stderr")
|
|
|
+ else:
|
|
|
+ cursor.execute("SELECT id,title,type,name,searchstring,directory \
|
|
|
+ FROM subscriptions")
|
|
|
+ subscriptions = cursor.fetchall()
|
|
|
+ database.close()
|
|
|
+ for element in subscriptions:
|
|
|
+ subscriptions_list.append(subscription.sub(id=element[0],
|
|
|
+ title=element[1], type=element[2], name=element[3],
|
|
|
+ search=element[4], directory=element[5], conf=conf))
|
|
|
+ for element in subscriptions_list:
|
|
|
+ element.CheckAndDelete()
|
|
|
+ try:
|
|
|
+ database = sqlite3.connect(conf.dbpath)
|
|
|
+ cursor = database.cursor()
|
|
|
+ except sqlite3.OperationalError:
|
|
|
+ printf(_("Could not access the database, please check path and "
|
|
|
+ "permissions and try again!"), outputlevel="default",
|
|
|
+ level=conf.outputlevel, descriptor="stderr")
|
|
|
+ else:
|
|
|
+ cursor.execute("VACUUM")
|
|
|
+ database.close()
|
|
|
+
|
|
|
elif options.license is True:
|
|
|
printf( """
|
|
|
stov is free software: you can redistribute it and/or modify
|