Skip to content

Commit

Permalink
Merge pull request #1 from zeroday0619/dev
Browse files Browse the repository at this point in the history
Add show URLs support
  • Loading branch information
Euiseo Cha authored Jun 21, 2021
2 parents 7a3de74 + 6ca58e4 commit d2b4cba
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 13 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,27 @@ print(uri)
```

## License
[MIT](LICENSE)

<img align="right" src="https://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png">

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.
10 changes: 1 addition & 9 deletions spotify_uri/__init__.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
8 changes: 6 additions & 2 deletions spotify_uri/parse.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
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
from spotify_uri.artist import Artist
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):
Expand Down Expand Up @@ -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}")
24 changes: 24 additions & 0 deletions spotify_uri/show.py
Original file line number Diff line number Diff line change
@@ -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)}"

0 comments on commit d2b4cba

Please sign in to comment.