From 5108fb5e7cbb51a05ed142ac54d0586d2c9fc305 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 5 Jul 2014 20:39:25 +0200 Subject: [YoutubeBatch] Little pattern fixup --- module/plugins/crypter/YoutubeBatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/crypter/YoutubeBatch.py') diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index e6976471c..4ba1a3c70 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -30,7 +30,7 @@ API_KEY = "AIzaSyCKnWLNlkX-L4oD1aEzqqhRw1zczeD6_k0" class YoutubeBatch(Crypter): __name__ = "YoutubeBatch" __type__ = "crypter" - __pattern__ = r'https?://(?:www\.)?(m\.)?youtube\.com/(?Puser|playlist|view_play_list)(/|.*?[?&](?:list|p)=)(?P[\w-]+)' + __pattern__ = r'https?://(?:www\.|m\.)?youtube\.com/(?Puser|playlist|view_play_list)(/|.*?[?&](?:list|p)=)(?P[\w-]+)' __version__ = "1.00" __description__ = """Youtube.com channel & playlist decrypter plugin""" __config__ = [("likes", "bool", "Grab user (channel) liked videos", False), -- cgit v1.2.3 From 04038a2cf0c4c2d9cc9a0c8e8bf9beb6426afae8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 10 Jul 2014 03:02:26 +0200 Subject: Use parseError instead PluginParseError + unified all download pattern attributes as LINK_PATTERN + removed some old patterns (not used anymore) + other code cosmetics --- module/plugins/crypter/YoutubeBatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/crypter/YoutubeBatch.py') diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index 4ba1a3c70..ade31df21 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -24,7 +24,7 @@ from module.common.json_layer import json_loads from module.plugins.Crypter import Crypter from module.utils import save_join -API_KEY = "AIzaSyCKnWLNlkX-L4oD1aEzqqhRw1zczeD6_k0" +API_URL = "AIzaSyCKnWLNlkX-L4oD1aEzqqhRw1zczeD6_k0" class YoutubeBatch(Crypter): -- cgit v1.2.3 From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/crypter/YoutubeBatch.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'module/plugins/crypter/YoutubeBatch.py') diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index ade31df21..1af9475eb 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: Walter Purcaro """ from urlparse import urljoin -- cgit v1.2.3 From 7b8c458cca7d21a029620f98e453f746fce69cd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 16:10:01 +0200 Subject: Prefer single quote for dict key name --- module/plugins/crypter/YoutubeBatch.py | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'module/plugins/crypter/YoutubeBatch.py') diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index 1af9475eb..dd5d937d5 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -45,21 +45,21 @@ class YoutubeBatch(Crypter): def getChannel(self, user): channels = self.api_response("channels", {"part": "id,snippet,contentDetails", "forUsername": user, "maxResults": "50"}) - if channels["items"]: - channel = channels["items"][0] - return {"id": channel["id"], - "title": channel["snippet"]["title"], - "relatedPlaylists": channel["contentDetails"]["relatedPlaylists"], + if channels['items']: + channel = channels['items'][0] + return {"id": channel['id'], + "title": channel['snippet']['title'], + "relatedPlaylists": channel['contentDetails']['relatedPlaylists'], "user": user} # One lone channel for user? def getPlaylist(self, p_id): playlists = self.api_response("playlists", {"part": "snippet", "id": p_id}) - if playlists["items"]: - playlist = playlists["items"][0] + if playlists['items']: + playlist = playlists['items'][0] return {"id": p_id, - "title": playlist["snippet"]["title"], - "channelId": playlist["snippet"]["channelId"], - "channelTitle": playlist["snippet"]["channelTitle"]} + "title": playlist['snippet']['title'], + "channelId": playlist['snippet']['channelId'], + "channelTitle": playlist['snippet']['channelTitle']} def _getPlaylists(self, id, token=None): req = {"part": "id", "maxResults": "50", "channelId": id} @@ -68,11 +68,11 @@ class YoutubeBatch(Crypter): playlists = self.api_response("playlists", req) - for playlist in playlists["items"]: - yield playlist["id"] + for playlist in playlists['items']: + yield playlist['id'] if "nextPageToken" in playlists: - for item in self._getPlaylists(id, playlists["nextPageToken"]): + for item in self._getPlaylists(id, playlists['nextPageToken']): yield item def getPlaylists(self, ch_id): @@ -85,11 +85,11 @@ class YoutubeBatch(Crypter): playlist = self.api_response("playlistItems", req) - for item in playlist["items"]: - yield item["contentDetails"]["videoId"] + for item in playlist['items']: + yield item['contentDetails']['videoId'] if "nextPageToken" in playlist: - for item in self._getVideosId(id, playlist["nextPageToken"]): + for item in self._getVideosId(id, playlist['nextPageToken']): yield item def getVideosId(self, p_id): @@ -106,18 +106,18 @@ class YoutubeBatch(Crypter): channel = self.getChannel(user) if channel: - playlists = self.getPlaylists(channel["id"]) - self.logDebug("%s playlist\s found on channel \"%s\"" % (len(playlists), channel["title"])) + playlists = self.getPlaylists(channel['id']) + self.logDebug("%s playlist\s found on channel \"%s\"" % (len(playlists), channel['title'])) - relatedplaylist = {p_name: self.getPlaylist(p_id) for p_name, p_id in channel["relatedPlaylists"].iteritems()} + relatedplaylist = {p_name: self.getPlaylist(p_id) for p_name, p_id in channel['relatedPlaylists'].iteritems()} self.logDebug("Channel's related playlists found = %s" % relatedplaylist.keys()) - relatedplaylist["uploads"]["title"] = "Unplaylisted videos" - relatedplaylist["uploads"]["checkDups"] = True #: checkDups flag + relatedplaylist['uploads']['title'] = "Unplaylisted videos" + relatedplaylist['uploads']['checkDups'] = True #: checkDups flag for p_name, p_data in relatedplaylist.iteritems(): if self.getConfig(p_name): - p_data["title"] += " of " + user + p_data['title'] += " of " + user playlists.append(p_data) else: playlists = [] @@ -131,9 +131,9 @@ class YoutubeBatch(Crypter): addedvideos = [] urlize = lambda x: "https://www.youtube.com/watch?v=" + x for p in playlists: - p_name = p["title"] - p_videos = self.getVideosId(p["id"]) - p_folder = save_join(self.config['general']['download_folder'], p["channelTitle"], p_name) + p_name = p['title'] + p_videos = self.getVideosId(p['id']) + p_folder = save_join(self.config['general']['download_folder'], p['channelTitle'], p_name) self.logDebug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) if not p_videos: -- cgit v1.2.3 From 8e47b0de30a25d0fd5dfb518bfe4e1e7beff93fd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:27:44 +0200 Subject: Key attributes cleanup for account, container and crypter plugins --- module/plugins/crypter/YoutubeBatch.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'module/plugins/crypter/YoutubeBatch.py') diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index dd5d937d5..dfac9140f 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -15,9 +15,10 @@ along with this program; if not, see . """ -from urlparse import urljoin import re +from urlparse import urljoin + from module.common.json_layer import json_loads from module.plugins.Crypter import Crypter from module.utils import save_join @@ -27,16 +28,19 @@ API_URL = "AIzaSyCKnWLNlkX-L4oD1aEzqqhRw1zczeD6_k0" class YoutubeBatch(Crypter): __name__ = "YoutubeBatch" + __version__ = "1.00" __type__ = "crypter" + __pattern__ = r'https?://(?:www\.|m\.)?youtube\.com/(?Puser|playlist|view_play_list)(/|.*?[?&](?:list|p)=)(?P[\w-]+)' - __version__ = "1.00" - __description__ = """Youtube.com channel & playlist decrypter plugin""" __config__ = [("likes", "bool", "Grab user (channel) liked videos", False), ("favorites", "bool", "Grab user (channel) favorite videos", False), ("uploads", "bool", "Grab channel unplaylisted videos", True)] + + __description__ = """Youtube.com channel & playlist decrypter plugin""" __author_name__ = "Walter Purcaro" __author_mail__ = "vuolter@gmail.com" + def api_response(self, ref, req): req.update({"key": API_KEY}) url = urljoin("https://www.googleapis.com/youtube/v3/", ref) -- cgit v1.2.3 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/crypter/YoutubeBatch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/crypter/YoutubeBatch.py') diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index dfac9140f..216fbb670 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -100,9 +100,9 @@ class YoutubeBatch(Crypter): return list(self._getVideosId(p_id)) def decrypt(self, pyfile): - match = re.match(self.__pattern__, pyfile.url) - m_id = match.group("ID") - m_type = match.group("TYPE") + m = re.match(self.__pattern__, pyfile.url) + m_id = m.group("ID") + m_type = m.group("TYPE") if m_type == "user": self.logDebug("Url recognized as Channel") -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro 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/crypter/YoutubeBatch.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'module/plugins/crypter/YoutubeBatch.py') diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index 216fbb670..1caca16bd 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -1,20 +1,5 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - import re from urlparse import urljoin @@ -28,8 +13,8 @@ API_URL = "AIzaSyCKnWLNlkX-L4oD1aEzqqhRw1zczeD6_k0" class YoutubeBatch(Crypter): __name__ = "YoutubeBatch" - __version__ = "1.00" __type__ = "crypter" + __version__ = "1.00" __pattern__ = r'https?://(?:www\.|m\.)?youtube\.com/(?Puser|playlist|view_play_list)(/|.*?[?&](?:list|p)=)(?P[\w-]+)' __config__ = [("likes", "bool", "Grab user (channel) liked videos", False), -- cgit v1.2.3