Browse Source

fixed encoding for data retrieved from html or youtube-dl

Helmut Pozimski 9 years ago
parent
commit
5ea642f126
2 changed files with 7 additions and 5 deletions
  1. 6 4
      lib_stov/noapi.py
  2. 1 1
      lib_stov/youtubeAPI.py

+ 6 - 4
lib_stov/noapi.py

@@ -16,6 +16,8 @@
 
 # -*- coding: utf8 -*-
 
+from __future__ import unicode_literals
+
 import subprocess
 import sys
 import lxml.html
@@ -98,9 +100,9 @@ class Connector(object):
             except subprocess.CalledProcessError:
                 raise stov_exceptions.YoutubeDlCallFailed()
             else:
-                videos_list.append(youtubeAPI.YtVideo(video_title,
-                                                        video_description,
-                                                        video_id))
+                videos_list.append(youtubeAPI.YtVideo(unicode(video_title, "utf-8"),
+                                                        unicode(video_description, "utf-8"),
+                                                        unicode(video_id)))
         return videos_list
 
     def ParseAPIData(self):
@@ -112,6 +114,6 @@ class Connector(object):
         self._fetch_title()
         videos = self._fetch_videos()
         channel = youtubeAPI.YtChannel()
-        channel.title = self._title
+        channel.title = unicode(self._title)
         channel.videos = videos
         return channel

+ 1 - 1
lib_stov/youtubeAPI.py

@@ -27,7 +27,7 @@ else:
     import urllib2
 
 from xml.dom.minidom import parseString
-import stov_exceptions
+from lib_stov import stov_exceptions
 
 
 class Parser(object):