From 855055b1922c95ce74c6f65b5249929f07011199 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Sat, 29 Dec 2018 20:18:20 -0600 Subject: [PATCH] Fixed extractors based in tests results --- src/extractors/mailru.py | 5 +++-- src/extractors/youtube.py | 2 ++ src/extractors/zaycev.py | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/extractors/mailru.py b/src/extractors/mailru.py index af88217..57f4657 100644 --- a/src/extractors/mailru.py +++ b/src/extractors/mailru.py @@ -18,11 +18,12 @@ class interface(object): def __init__(self): self.results = [] - self.needs_transcode = False log.debug("Started extraction service for mail.ru music") def search(self, text, page=1): + if text == "" or text == None: + raise ValueError("Text must be passed and should not be blank.") site = 'https://my.mail.ru/music/search/%s' % (text) log.debug("Retrieving data from {0}...".format(site,)) r = requests.get(site) @@ -35,7 +36,7 @@ class interface(object): s.title = data[0].text.replace("\n", "").replace("\t", "") # s.artist = data[1].text.replace("\n", "").replace("\t", "") # print(data) - s.url = u"https://my.mail.ru"+urlparse.quote(data[0].__dict__["attrs"]["href"]) + s.url = u"https://my.mail.ru"+urlparse.quote(data[0].__dict__["attrs"]["href"].encode("utf-8")) self.results.append(s) log.debug("{0} results found.".format(len(self.results))) diff --git a/src/extractors/youtube.py b/src/extractors/youtube.py index f5203b3..88f01c6 100644 --- a/src/extractors/youtube.py +++ b/src/extractors/youtube.py @@ -23,6 +23,8 @@ class interface(object): log.debug("started extraction service for {0}".format(self.name,)) def search(self, text, page=1): + if text == "" or text == None: + raise ValueError("Text must be passed and should not be blank.") if text.startswith("https") or text.startswith("http"): return self.search_from_url(text) type = "video" diff --git a/src/extractors/zaycev.py b/src/extractors/zaycev.py index 74b37da..12fcafd 100644 --- a/src/extractors/zaycev.py +++ b/src/extractors/zaycev.py @@ -19,6 +19,8 @@ class interface(object): log.debug("Started extraction service for zaycev.net") def search(self, text, page=1): + if text == "" or text == None: + raise ValueError("Text must be passed and should not be blank.") site = "http://zaycev.net/search.html?query_search=%s" % (text,) log.debug("Retrieving data from {0}...".format(site,)) r = requests.get(site)