From 05d258d98dd8c2faf0b769840fa1e3c4acccdce8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:25:14 +0200 Subject: Fix and improve 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 --- module/plugins/hoster/SoundcloudCom.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index a1ec1378a..f4a81059b 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -19,24 +19,24 @@ class SoundcloudCom(Hoster): # default UserAgent of HTTPRequest fails for this hoster so we use this one self.req.http.c.setopt(pycurl.USERAGENT, 'Mozilla/5.0') page = self.load(pyfile.url) - match = re.search(r'
.*?)"', page) - if match: - clientId = match.group("CID") + found = re.search(r'"clientID":"(?P.*?)"', page) + if found: + clientId = found.group("CID") if len(clientId) <= 0: clientId = "b45b1aa10f1ac2941910a7f0d10f8e28" - match = re.search(r'\s(?P.*?)\s</em>', page) - if match: - pyfile.name = match.group("TITLE") + ".mp3" + found = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', page) + if found: + pyfile.name = found.group("TITLE") + ".mp3" else: pyfile.name = re.match(self.__pattern__, pyfile.url).group("SID") + ".mp3" -- cgit v1.2.3 From 9395182da7afed55a29bde1c7cbefe4204e783f0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 20 Jul 2014 03:02:09 +0200 Subject: Store all re.search/match object as "m" instead "found" --- module/plugins/hoster/SoundcloudCom.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index f4a81059b..75a1cffeb 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -19,24 +19,24 @@ class SoundcloudCom(Hoster): # default UserAgent of HTTPRequest fails for this hoster so we use this one self.req.http.c.setopt(pycurl.USERAGENT, 'Mozilla/5.0') page = self.load(pyfile.url) - found = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>[0-9]*)"', page) + m = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>[0-9]*)"', page) songId = clientId = "" - if found: - songId = found.group("ID") + if m: + songId = m.group("ID") if len(songId) <= 0: self.logError("Could not find song id") self.offline() else: - found = re.search(r'"clientID":"(?P<CID>.*?)"', page) - if found: - clientId = found.group("CID") + m = re.search(r'"clientID":"(?P<CID>.*?)"', page) + if m: + clientId = m.group("CID") if len(clientId) <= 0: clientId = "b45b1aa10f1ac2941910a7f0d10f8e28" - found = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', page) - if found: - pyfile.name = found.group("TITLE") + ".mp3" + m = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', page) + if m: + pyfile.name = m.group("TITLE") + ".mp3" else: pyfile.name = re.match(self.__pattern__, pyfile.url).group("SID") + ".mp3" -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hoster/SoundcloudCom.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 75a1cffeb..05fe897d2 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -import re import pycurl +import re from module.plugins.Hoster import Hoster @@ -9,12 +9,15 @@ from module.plugins.Hoster import Hoster class SoundcloudCom(Hoster): __name__ = "SoundcloudCom" __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.*?)/(?P<SID>.*)' __version__ = "0.1" + + __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.*?)/(?P<SID>.*)' + __description__ = """SoundCloud.com hoster plugin""" __author_name__ = "Peekayy" __author_mail__ = "peekayy.dev@gmail.com" + def process(self, pyfile): # default UserAgent of HTTPRequest fails for this hoster so we use this one self.req.http.c.setopt(pycurl.USERAGENT, 'Mozilla/5.0') -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/hoster/SoundcloudCom.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 05fe897d2..d88ade399 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -14,8 +14,7 @@ class SoundcloudCom(Hoster): __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.*?)/(?P<SID>.*)' __description__ = """SoundCloud.com hoster plugin""" - __author_name__ = "Peekayy" - __author_mail__ = "peekayy.dev@gmail.com" + __authors__ = [("Peekayy", "peekayy.dev@gmail.com")] def process(self, pyfile): -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/hoster/SoundcloudCom.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index d88ade399..1fa1ec6ea 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -14,6 +14,7 @@ class SoundcloudCom(Hoster): __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.*?)/(?P<SID>.*)' __description__ = """SoundCloud.com hoster plugin""" + __license__ = "GPLv3" __authors__ = [("Peekayy", "peekayy.dev@gmail.com")] -- cgit v1.2.3 From f76e5c2336718dca9da8033ba22cd83c72c7b3b3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 11 Oct 2014 15:14:28 +0200 Subject: Pattern update 1 --- module/plugins/hoster/SoundcloudCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 1fa1ec6ea..9305a2142 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -22,7 +22,7 @@ class SoundcloudCom(Hoster): # default UserAgent of HTTPRequest fails for this hoster so we use this one self.req.http.c.setopt(pycurl.USERAGENT, 'Mozilla/5.0') page = self.load(pyfile.url) - m = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>[0-9]*)"', page) + m = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>\d*)"', page) songId = clientId = "" if m: songId = m.group("ID") -- cgit v1.2.3 From 9f2ebe486a3e155fb6a60e07cccb77ab6a772eb2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 26 Oct 2014 02:31:54 +0200 Subject: Extend translation support in plugins + a lot of code cosmetics and typo fixes --- module/plugins/hoster/SoundcloudCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 9305a2142..1228e85e9 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -27,7 +27,7 @@ class SoundcloudCom(Hoster): if m: songId = m.group("ID") if len(songId) <= 0: - self.logError("Could not find song id") + self.logError(_("Could not find song id")) self.offline() else: m = re.search(r'"clientID":"(?P<CID>.*?)"', page) -- cgit v1.2.3 From 34984dae733c3f3d47b41a0acfba3724d53c65a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 28 Oct 2014 16:52:10 +0100 Subject: Code cosmetics: plugin class attributes --- module/plugins/hoster/SoundcloudCom.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 1228e85e9..71cfb6b27 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -7,15 +7,15 @@ from module.plugins.Hoster import Hoster class SoundcloudCom(Hoster): - __name__ = "SoundcloudCom" - __type__ = "hoster" + __name__ = "SoundcloudCom" + __type__ = "hoster" __version__ = "0.1" __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.*?)/(?P<SID>.*)' __description__ = """SoundCloud.com hoster plugin""" - __license__ = "GPLv3" - __authors__ = [("Peekayy", "peekayy.dev@gmail.com")] + __license__ = "GPLv3" + __authors__ = [("Peekayy", "peekayy.dev@gmail.com")] def process(self, pyfile): -- cgit v1.2.3 From 6151e81fa0b325dffda3da4228d5821e73db3ef3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 9 Dec 2014 01:19:46 +0100 Subject: Fix __version__ format in some plugins --- module/plugins/hoster/SoundcloudCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 71cfb6b27..79c8a2f1e 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -9,7 +9,7 @@ from module.plugins.Hoster import Hoster class SoundcloudCom(Hoster): __name__ = "SoundcloudCom" __type__ = "hoster" - __version__ = "0.1" + __version__ = "0.10" __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.*?)/(?P<SID>.*)' -- cgit v1.2.3 From 854efeb463bd98cb8e22f1f78f5ce97e6c0ab49f Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 22 Dec 2014 16:45:04 +0100 Subject: Spare code cosmetics --- module/plugins/hoster/SoundcloudCom.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 79c8a2f1e..4665dff05 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -25,23 +25,23 @@ class SoundcloudCom(Hoster): m = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>\d*)"', page) songId = clientId = "" if m: - songId = m.group("ID") + songId = m.group('ID') if len(songId) <= 0: self.logError(_("Could not find song id")) self.offline() else: m = re.search(r'"clientID":"(?P<CID>.*?)"', page) if m: - clientId = m.group("CID") + clientId = m.group('CID') if len(clientId) <= 0: clientId = "b45b1aa10f1ac2941910a7f0d10f8e28" m = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', page) if m: - pyfile.name = m.group("TITLE") + ".mp3" + pyfile.name = m.group('TITLE') + ".mp3" else: - pyfile.name = re.match(self.__pattern__, pyfile.url).group("SID") + ".mp3" + pyfile.name = re.match(self.__pattern__, pyfile.url).group('SID') + ".mp3" # url to retrieve the actual song url page = self.load("https://api.sndcdn.com/i1/tracks/%s/streams" % songId, get={"client_id": clientId}) @@ -49,7 +49,7 @@ class SoundcloudCom(Hoster): # for now we choose the first stream found in all cases # it could be improved if relevant for this hoster streams = [ - (result.group("QUALITY"), result.group("URL")) + (result.group('QUALITY'), result.group('URL')) for result in re.finditer(r'"(?P<QUALITY>.*?)":"(?P<URL>.*?)"', page) ] self.logDebug("Found Streams", streams) -- cgit v1.2.3 From cdb06469a640c1875229903a2dbdfa8be469b5bc Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 27 Dec 2014 13:52:30 +0100 Subject: Improve a lot of plugin __pattern__ --- module/plugins/hoster/SoundcloudCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/SoundcloudCom.py') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 4665dff05..3eb546604 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -11,7 +11,7 @@ class SoundcloudCom(Hoster): __type__ = "hoster" __version__ = "0.10" - __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.*?)/(?P<SID>.*)' + __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.+?)/(?P<SID>.+)' __description__ = """SoundCloud.com hoster plugin""" __license__ = "GPLv3" -- cgit v1.2.3