From 30a8d73abcdd29296c45c6cea6d7a0d5a43a46bb Mon Sep 17 00:00:00 2001 From: Euiseo Cha Date: Mon, 21 Jun 2021 10:50:40 +0900 Subject: [PATCH 1/2] chore: Update License and README.md --- LICENSE | 2 +- README.md | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 28e2ec0..5b28a2c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 zeroday0619 +Copyright (c) 2021 Euiseo Cha Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a640069..e77347f 100644 --- a/README.md +++ b/README.md @@ -61,4 +61,27 @@ print(uri) ``` ## License -[MIT](LICENSE) + + + +Distributed under the [MIT License](LICENSE): + +Copyright © 2021 [Euiseo Cha](https://github.com/zeroday0619) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file From 6ca58e4b96c46b45d99c7fdde1500cfe0d68131a Mon Sep 17 00:00:00 2001 From: Euiseo Cha Date: Mon, 21 Jun 2021 15:21:16 +0900 Subject: [PATCH 2/2] feat: add show URLs support --- spotify_uri/__init__.py | 10 +--------- spotify_uri/parse.py | 8 ++++++-- spotify_uri/show.py | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 spotify_uri/show.py diff --git a/spotify_uri/__init__.py b/spotify_uri/__init__.py index c01d0af..911b134 100644 --- a/spotify_uri/__init__.py +++ b/spotify_uri/__init__.py @@ -1,14 +1,6 @@ - -__version__ = "1.0.2" +__version__ = "1.0.3" from spotify_uri.parse import parse as _parse -from spotify_uri.search import Search as _Search -from spotify_uri.local import Local as _Local -from spotify_uri.playlist import Playlist as _Playlist -from spotify_uri.artist import Artist as _Artist -from spotify_uri.album import Album as _Album -from spotify_uri.track import Track as _Track -from spotify_uri.user import User as _User from spotify_uri.spotify import SpotifyUri diff --git a/spotify_uri/parse.py b/spotify_uri/parse.py index adca783..4e18739 100644 --- a/spotify_uri/parse.py +++ b/spotify_uri/parse.py @@ -1,5 +1,7 @@ from typing import List from urllib.parse import urlparse, parse_qs +from spotify_uri.spotify import SpotifyUri +from spotify_uri.util import decode from spotify_uri.local import Local from spotify_uri.search import Search from spotify_uri.playlist import Playlist @@ -7,9 +9,9 @@ from spotify_uri.album import Album from spotify_uri.track import Track from spotify_uri.episode import Episode +from spotify_uri.show import Show from spotify_uri.user import User -from spotify_uri.util import decode -from spotify_uri.spotify import SpotifyUri + def parse(_input: str): @@ -85,5 +87,7 @@ def parseParts(uri: str, parts: List[str]): return Track(uri, parts[2]) if parts[1] == "episode": return Episode(uri, parts[2]) + if parts[1] == "show": + return Show(uri, parts[2]) raise TypeError(f"Could not determine type for: {uri}") diff --git a/spotify_uri/show.py b/spotify_uri/show.py new file mode 100644 index 0000000..c97a5f4 --- /dev/null +++ b/spotify_uri/show.py @@ -0,0 +1,24 @@ +from typing import Any +from spotify_uri.spotify import SpotifyUri +from spotify_uri.util import encode + + +class Show(SpotifyUri): + def __init__(self, uri: str, _id: str) -> None: + self.type = "show" + self.id = _id + super(Show, self).__init__(uri) + + @staticmethod + def is_(v: Any) -> bool: + x = v is Show + if x: + return v.type == "show" + else: + return False + + def toURI(self) -> str: + return f"spotify:{self.type}:{encode(self.id)}" + + def toURL(self) -> str: + return f"/{self.type}/{encode(self.id)}" \ No newline at end of file