From f01fd21ef9e761224163331a682c6c65167adc23 Mon Sep 17 00:00:00 2001 From: Kepoor Hampond Date: Sat, 10 Jun 2017 18:28:26 -0700 Subject: [PATCH 1/6] Apparently it was just some wierd apostrophe in a unicode format --- irs/ripper.py | 8 +++++--- irs/utils.py | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/irs/ripper.py b/irs/ripper.py index 7603a41..1b3b3cb 100644 --- a/irs/ripper.py +++ b/irs/ripper.py @@ -1,3 +1,5 @@ +# _*_ coding:utf-8 _*_ + # System import sys import os @@ -141,8 +143,8 @@ class Ripper: raise ValueError("Must specify song_title/artist in `args` with \ init, or in method arguments.") - search_terms = str(song) + " " + str(artist - ) + " " + str(additional_search) + search_terms = song + " " + artist + " " + additional_search + query_string = urlencode({"search_query": ( search_terms.encode('utf-8'))}) link = "http://www.youtube.com/results?" + query_string @@ -376,7 +378,7 @@ init, or in method arguments.") video_url, video_title = self.find_yt_url(song, artist) - print(self.args["hook-text"].get("song").format(song, artist)) + print(self.args["hook-text"].get("song").decode().format(song, artist)) file_name = data["file_prefix"] + ObjManip.blank(song, False) + ".mp3" diff --git a/irs/utils.py b/irs/utils.py index f5a0c8a..fc8e56b 100644 --- a/irs/utils.py +++ b/irs/utils.py @@ -1,4 +1,5 @@ -# -*- coding: UTF-8 -*- +# _*_ coding:utf-8 _*_ + # ======= # Imports @@ -97,10 +98,10 @@ class ObjManip: # Object Manipulation def blank(string, downcase=True): import re regex = re.compile('[^a-zA-Z0-9\ ]') - string = regex.sub('', str(string)) + string = regex.sub('', string.encode("utf8")) if downcase: string = string.lower() - return ' '.join(string.split()) + return ' '.join(string.decode().split()) def blank_include(this, includes_this): this = ObjManip.blank(this) From c2b05730404e20420063f8c2bc4307a2f95eaf7a Mon Sep 17 00:00:00 2001 From: Kepoor Hampond Date: Sat, 10 Jun 2017 18:33:32 -0700 Subject: [PATCH 2/6] Better option --- irs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irs/utils.py b/irs/utils.py index fc8e56b..476ab88 100644 --- a/irs/utils.py +++ b/irs/utils.py @@ -98,7 +98,7 @@ class ObjManip: # Object Manipulation def blank(string, downcase=True): import re regex = re.compile('[^a-zA-Z0-9\ ]') - string = regex.sub('', string.encode("utf8")) + string = regex.sub('', string.encode('ascii', 'ignore')) if downcase: string = string.lower() return ' '.join(string.decode().split()) From 5d2537b236e49357c54e5097d895e0846d7e5ad4 Mon Sep 17 00:00:00 2001 From: Kepoor Hampond Date: Sat, 10 Jun 2017 18:40:11 -0700 Subject: [PATCH 3/6] Try it again --- irs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irs/utils.py b/irs/utils.py index 476ab88..98aa891 100644 --- a/irs/utils.py +++ b/irs/utils.py @@ -98,7 +98,7 @@ class ObjManip: # Object Manipulation def blank(string, downcase=True): import re regex = re.compile('[^a-zA-Z0-9\ ]') - string = regex.sub('', string.encode('ascii', 'ignore')) + string = regex.sub('', string.decode("utf8")) if downcase: string = string.lower() return ' '.join(string.decode().split()) From fa64378c2b3455841210a7c337fc96180962f4ea Mon Sep 17 00:00:00 2001 From: Kepoor Hampond Date: Sat, 10 Jun 2017 18:43:42 -0700 Subject: [PATCH 4/6] Once more? --- irs/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/irs/utils.py b/irs/utils.py index 98aa891..ff6cc9f 100644 --- a/irs/utils.py +++ b/irs/utils.py @@ -98,7 +98,10 @@ class ObjManip: # Object Manipulation def blank(string, downcase=True): import re regex = re.compile('[^a-zA-Z0-9\ ]') - string = regex.sub('', string.decode("utf8")) + if sys.version_info == 2: + string = regex.sub('', string.decode("utf8")) + else: + string = regex.sub('', string) if downcase: string = string.lower() return ' '.join(string.decode().split()) From e61036dc51859b9345e70db21fb712147c2223f2 Mon Sep 17 00:00:00 2001 From: Kepoor Hampond Date: Sat, 10 Jun 2017 18:48:30 -0700 Subject: [PATCH 5/6] Maybe again? --- irs/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/irs/utils.py b/irs/utils.py index ff6cc9f..f1c7277 100644 --- a/irs/utils.py +++ b/irs/utils.py @@ -96,15 +96,16 @@ class ObjManip: # Object Manipulation return False def blank(string, downcase=True): + if downcase: + string = string.lower() import re regex = re.compile('[^a-zA-Z0-9\ ]') if sys.version_info == 2: string = regex.sub('', string.decode("utf8")) + return ' '.join(string.decode().split()) else: string = regex.sub('', string) - if downcase: - string = string.lower() - return ' '.join(string.decode().split()) + return ' '.join(string.split()) def blank_include(this, includes_this): this = ObjManip.blank(this) From c919e1720ea9905ca424bdf4b4163f5bba2ffdfd Mon Sep 17 00:00:00 2001 From: Kepoor Hampond Date: Sat, 10 Jun 2017 18:53:49 -0700 Subject: [PATCH 6/6] Minor bug fixes --- irs/ripper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/irs/ripper.py b/irs/ripper.py index 1b3b3cb..8993190 100644 --- a/irs/ripper.py +++ b/irs/ripper.py @@ -378,7 +378,11 @@ init, or in method arguments.") video_url, video_title = self.find_yt_url(song, artist) - print(self.args["hook-text"].get("song").decode().format(song, artist)) + if sys.version_info[0] == 2: + print(self.args["hook-text"].get("song").decode().format(song, + artist)) + else: + print(self.args["hook-text"].get("song").format(song, artist)) file_name = data["file_prefix"] + ObjManip.blank(song, False) + ".mp3"