|
@@ -21,8 +21,7 @@ import gettext
|
|
|
import urllib2
|
|
|
import sqlite3
|
|
|
|
|
|
-import feedparser
|
|
|
-
|
|
|
+import youtubeAPI
|
|
|
import youtube
|
|
|
|
|
|
from outputhelper import printf
|
|
@@ -85,10 +84,8 @@ class sub(object):
|
|
|
"new video was NOT added! Please check permissions and try again."),
|
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
|
|
|
|
- for i in self.__ParsedResponse.entries:
|
|
|
- self.__ytid = i.link.partition("=")
|
|
|
- self.__ytid = self.__ytid[2].partition("&")
|
|
|
- self.__ytid = self.__ytid[0]
|
|
|
+ for i in self.__ParsedResponse.videos:
|
|
|
+ self.__ytid = i.ytid
|
|
|
self.__videoquery = "SELECT id FROM videos WHERE ytid=?"
|
|
|
self.__cursor.execute(self.__videoquery, (self.__ytid,))
|
|
|
self.__tmpid = self.__cursor.fetchall()
|
|
@@ -162,7 +159,7 @@ class sub(object):
|
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
|
else:
|
|
|
self.__cursor = self.__connection.cursor()
|
|
|
- self.__title = self.__ParsedResponse.feed.title
|
|
|
+ self.__title = self.__ParsedResponse.title
|
|
|
self.__directory = self.__name + "_" + self.__search.replace(" ", "_")
|
|
|
self.__query = "INSERT INTO subscriptions (title, type, searchstring, \
|
|
|
directory, name) VALUES (?, ?, ?, ?, ?)"
|
|
@@ -184,7 +181,9 @@ class sub(object):
|
|
|
|
|
|
"""
|
|
|
try:
|
|
|
- self.__APIResponse = urllib2.urlopen(self.__APIURL)
|
|
|
+ self.__ConnectAPI = urllib2.urlopen(self.__APIURL)
|
|
|
+ self.__APIResponse = self.__ConnectAPI.read()
|
|
|
+ self.__ConnectAPI.close()
|
|
|
except IOError:
|
|
|
printf(_("Could not get API data, maybe the API "
|
|
|
"is down or you have given wrong parameters"
|
|
@@ -192,22 +191,23 @@ class sub(object):
|
|
|
outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
|
|
|
sys.exit(1)
|
|
|
else:
|
|
|
- self.__ParsedResponse = feedparser.parse(self.__APIResponse)
|
|
|
+ parser = youtubeAPI.Parser(self.__APIResponse)
|
|
|
+ self.__ParsedResponse = parser.parse()
|
|
|
|
|
|
def __ConstructAPIURL(self):
|
|
|
"""Constructs the API URL which is used to retrieve API data"""
|
|
|
if self.__type == "channel":
|
|
|
self.__APIURL = "https://gdata.youtube.com/feeds/api/users/"\
|
|
|
- + urllib2.quote(self.__name) + "/uploads/"
|
|
|
+ + urllib2.quote(self.__name) + "/uploads/" + "?v=2"
|
|
|
if self.__search != "":
|
|
|
- self.__APIURL = self.__APIURL + "?q=" + "%22"\
|
|
|
+ self.__APIURL = self.__APIURL + "&q=" + "%22"\
|
|
|
+ urllib2.quote(self.__search) + "%22"
|
|
|
elif self.__type == "search":
|
|
|
self.__APIURL = "http://gdata.youtube.com/feeds/api/videos?q="\
|
|
|
- + urllib2.quote(self.__search) + "&max-results=10"
|
|
|
+ + urllib2.quote(self.__search) + "&max-results=10" + "&v=2"
|
|
|
elif self.__type == "playlist":
|
|
|
self.__APIURL = "https://gdata.youtube.com/feeds/api/playlists/"\
|
|
|
- + "%20" + urllib2.quote(self.__name) + "%20"
|
|
|
+ + "%20" + urllib2.quote(self.__name) + "%20" + "?v=2"
|
|
|
else:
|
|
|
printf(_("None or invalid subscription type given, "
|
|
|
"please check the type option and try again"),
|