|
@@ -85,11 +85,16 @@ class sub(object):
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
|
|
|
|
for i in self.__ParsedResponse.videos:
|
|
for i in self.__ParsedResponse.videos:
|
|
|
|
+ printf(_('Checking if video "%s" exists in the database' %i.title),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
self.__ytid = i.ytid
|
|
self.__ytid = i.ytid
|
|
self.__videoquery = "SELECT id FROM videos WHERE ytid=?"
|
|
self.__videoquery = "SELECT id FROM videos WHERE ytid=?"
|
|
self.__cursor.execute(self.__videoquery, (self.__ytid,))
|
|
self.__cursor.execute(self.__videoquery, (self.__ytid,))
|
|
self.__tmpid = self.__cursor.fetchall()
|
|
self.__tmpid = self.__cursor.fetchall()
|
|
if self.__tmpid == []:
|
|
if self.__tmpid == []:
|
|
|
|
+ printf(_("Video %s not found in database, inserting..." % i.title),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel,
|
|
|
|
+ descriptor="stderr")
|
|
self.__query = "INSERT INTO videos (title, description, \
|
|
self.__query = "INSERT INTO videos (title, description, \
|
|
ytid, subscription_id, downloaded) VALUES (?, ?, ?, ?, ?)"
|
|
ytid, subscription_id, downloaded) VALUES (?, ?, ?, ?, ?)"
|
|
self.__data = (i.title, i.description, self.__ytid, self.__ID, 0)
|
|
self.__data = (i.title, i.description, self.__ytid, self.__ID, 0)
|
|
@@ -112,11 +117,16 @@ class sub(object):
|
|
"Please check permissions and try again."),
|
|
"Please check permissions and try again."),
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
|
|
|
|
|
|
+ printf(_("Getting all videos for subscription %s from database"
|
|
|
|
+ % self.__title), outputlevel="verbose", level=self.__conf.outputlevel,
|
|
|
|
+ descriptor="stderr")
|
|
self.__videoquerybysubscription = "SELECT id, title, description, \
|
|
self.__videoquerybysubscription = "SELECT id, title, description, \
|
|
ytid, downloaded FROM videos WHERE subscription_id=?"
|
|
ytid, downloaded FROM videos WHERE subscription_id=?"
|
|
self.__cursor.execute(self.__videoquerybysubscription, (self.__ID,))
|
|
self.__cursor.execute(self.__videoquerybysubscription, (self.__ID,))
|
|
self.__videodata = self.__cursor.fetchall()
|
|
self.__videodata = self.__cursor.fetchall()
|
|
for i in self.__videodata:
|
|
for i in self.__videodata:
|
|
|
|
+ printf(_("Got video %s" % i[1]),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
self.__videos.append(youtube.video(id=i[0],
|
|
self.__videos.append(youtube.video(id=i[0],
|
|
title=i[1], description=i[2], ytid=i[3],
|
|
title=i[1], description=i[2], ytid=i[3],
|
|
downloaded=i[4], conf=self.__conf))
|
|
downloaded=i[4], conf=self.__conf))
|
|
@@ -160,11 +170,17 @@ class sub(object):
|
|
else:
|
|
else:
|
|
self.__cursor = self.__connection.cursor()
|
|
self.__cursor = self.__connection.cursor()
|
|
self.__title = self.__ParsedResponse.title
|
|
self.__title = self.__ParsedResponse.title
|
|
|
|
+ printf(_("Found subscription title %s" % self.__title),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
self.__directory = self.__name + "_" + self.__search.replace(" ", "_")
|
|
self.__directory = self.__name + "_" + self.__search.replace(" ", "_")
|
|
|
|
+ printf(_("Directory: %s" % self.__directory),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
self.__query = "INSERT INTO subscriptions (title, type, searchstring, \
|
|
self.__query = "INSERT INTO subscriptions (title, type, searchstring, \
|
|
directory, name) VALUES (?, ?, ?, ?, ?)"
|
|
directory, name) VALUES (?, ?, ?, ?, ?)"
|
|
self.__data = (self.__title, self.__type, self.__search,
|
|
self.__data = (self.__title, self.__type, self.__search,
|
|
self.__directory, self.__name)
|
|
self.__directory, self.__name)
|
|
|
|
+ printf(_("Writing subscription info into database..."),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
self.__cursor.execute(self.__query, self.__data)
|
|
self.__cursor.execute(self.__query, self.__data)
|
|
self.__connection.commit()
|
|
self.__connection.commit()
|
|
|
|
|
|
@@ -173,6 +189,8 @@ class sub(object):
|
|
self.__cursor.execute(self.__query, self.__data)
|
|
self.__cursor.execute(self.__query, self.__data)
|
|
self.__ID = self.__cursor.fetchone()
|
|
self.__ID = self.__cursor.fetchone()
|
|
self.__ID = self.__ID[0]
|
|
self.__ID = self.__ID[0]
|
|
|
|
+ printf(_("Subscription got internal ID %s" %self.__ID),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
self.__connection.close()
|
|
self.__connection.close()
|
|
|
|
|
|
def __ParseAPIData(self):
|
|
def __ParseAPIData(self):
|
|
@@ -181,7 +199,11 @@ class sub(object):
|
|
|
|
|
|
"""
|
|
"""
|
|
try:
|
|
try:
|
|
|
|
+ printf(_("Connectiong to youtube API."),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
self.__ConnectAPI = urllib2.urlopen(self.__APIURL)
|
|
self.__ConnectAPI = urllib2.urlopen(self.__APIURL)
|
|
|
|
+ printf(_("Connection established, reading data."),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
self.__APIResponse = self.__ConnectAPI.read()
|
|
self.__APIResponse = self.__ConnectAPI.read()
|
|
self.__ConnectAPI.close()
|
|
self.__ConnectAPI.close()
|
|
except IOError:
|
|
except IOError:
|
|
@@ -191,6 +213,8 @@ class sub(object):
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
sys.exit(1)
|
|
sys.exit(1)
|
|
else:
|
|
else:
|
|
|
|
+ printf(_("Parsing youtube API response."),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
parser = youtubeAPI.Parser(self.__APIResponse)
|
|
parser = youtubeAPI.Parser(self.__APIResponse)
|
|
self.__ParsedResponse = parser.parse()
|
|
self.__ParsedResponse = parser.parse()
|
|
|
|
|
|
@@ -212,6 +236,8 @@ class sub(object):
|
|
printf(_("None or invalid subscription type given, "
|
|
printf(_("None or invalid subscription type given, "
|
|
"please check the type option and try again"),
|
|
"please check the type option and try again"),
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
|
|
+ printf(_("Constructed the following API URL: %s" % self.__APIURL),
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
|
|
def CheckAndDelete(self):
|
|
def CheckAndDelete(self):
|
|
"""Checks if a video still exists in the current API response and deletes
|
|
"""Checks if a video still exists in the current API response and deletes
|
|
it if it doesn't
|
|
it if it doesn't
|
|
@@ -230,5 +256,5 @@ class sub(object):
|
|
descriptor="stdout")
|
|
descriptor="stdout")
|
|
else:
|
|
else:
|
|
printf(_("Videos %s could not be deleted from the database"),
|
|
printf(_("Videos %s could not be deleted from the database"),
|
|
- outputlevel="default", level=self.__conf.outputlevel,
|
|
|
|
|
|
+ outputlevel="verbose", level=self.__conf.outputlevel,
|
|
descriptor="stderr")
|
|
descriptor="stderr")
|