|
@@ -16,16 +16,11 @@
|
|
|
|
|
|
# -*- coding: utf8 -*-
|
|
|
|
|
|
-from __future__ import unicode_literals
|
|
|
-
|
|
|
import subprocess
|
|
|
import sys
|
|
|
import lxml.html
|
|
|
-
|
|
|
-if sys.version_info >= (3,):
|
|
|
- import urllib.request as urllib2
|
|
|
-else:
|
|
|
- import urllib2
|
|
|
+import urllib.parse
|
|
|
+import urllib.request
|
|
|
|
|
|
from lib_stov import stov_exceptions
|
|
|
|
|
@@ -60,18 +55,18 @@ class Connector(object):
|
|
|
def _construct_url(self):
|
|
|
if self._type == "channel":
|
|
|
self._url = "https://www.youtube.com/user/%s" \
|
|
|
- % urllib2.quote(self._name)
|
|
|
+ % urllib.parse.quote(self._name)
|
|
|
elif self._type == "search":
|
|
|
self._url = "https://www.youtube.com/results?search_query=%s"\
|
|
|
- % urllib2.quote(self._search)
|
|
|
+ % urllib.parse.quote(self._search)
|
|
|
elif self._type == "playlist":
|
|
|
self._url = "https://www.youtube.com/playlist?list=%s" \
|
|
|
- % urllib2.quote(self._name)
|
|
|
+ % urllib.parse.quote(self._name)
|
|
|
|
|
|
def _fetch_title(self):
|
|
|
"""Retrieves the title of the HTML page to use as a title for the
|
|
|
subscription."""
|
|
|
- data = urllib2.urlopen(self._url)
|
|
|
+ data = urllib.request.urlopen(self._url)
|
|
|
parsed_html = lxml.html.parse(data)
|
|
|
data.close()
|
|
|
i = 0
|
|
@@ -131,9 +126,9 @@ class Connector(object):
|
|
|
raise stov_exceptions.YoutubeDlCallFailed()
|
|
|
else:
|
|
|
videos_list.append(YtVideo(
|
|
|
- unicode(video_title, "utf-8"),
|
|
|
- unicode(video_description, "utf-8"),
|
|
|
- unicode(video_id)))
|
|
|
+ video_title,
|
|
|
+ video_description,
|
|
|
+ video_id))
|
|
|
return videos_list
|
|
|
|
|
|
def ParseAPIData(self, existing_videos):
|
|
@@ -145,6 +140,6 @@ class Connector(object):
|
|
|
self._fetch_title()
|
|
|
videos = self._fetch_videos(existing_videos)
|
|
|
channel = YtChannel()
|
|
|
- channel.title = unicode(self._title)
|
|
|
+ channel.title = self._title
|
|
|
channel.videos = videos
|
|
|
return channel
|