yutipy 1.1.0__py3-none-any.whl → 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of yutipy might be problematic. Click here for more details.

yutipy/deezer.py CHANGED
@@ -28,7 +28,7 @@ class Deezer:
28
28
 
29
29
  def __exit__(self, exc_type, exc_value, exc_traceback) -> None:
30
30
  """Exits the runtime context related to this object."""
31
- self._close_session()
31
+ self.close_session()
32
32
 
33
33
  def close_session(self) -> None:
34
34
  """Closes the current session."""
yutipy/itunes.py CHANGED
@@ -29,7 +29,7 @@ class Itunes:
29
29
 
30
30
  def __exit__(self, exc_type, exc_value, exc_traceback) -> None:
31
31
  """Exits the runtime context related to this object."""
32
- self._close_session()
32
+ self.close_session()
33
33
 
34
34
  def close_session(self) -> None:
35
35
  """Closes the current session."""
yutipy/kkbox.py CHANGED
@@ -56,6 +56,7 @@ class KKBox:
56
56
  self.__header, self.__expires_in = self.__authenticate()
57
57
  self.__start_time = time.time()
58
58
  self._is_session_closed = False
59
+ self.valid_territories = ["HK", "JP", "MY", "SG", "TW"]
59
60
 
60
61
  def __enter__(self):
61
62
  """Enters the runtime context related to this object."""
@@ -63,7 +64,7 @@ class KKBox:
63
64
 
64
65
  def __exit__(self, exc_type, exc_value, exc_traceback):
65
66
  """Exits the runtime context related to this object."""
66
- self._close_session()
67
+ self.close_session()
67
68
 
68
69
  def close_session(self) -> None:
69
70
  """Closes the current session."""
@@ -174,6 +175,58 @@ class KKBox:
174
175
 
175
176
  return self._find_music_info(artist, song, response.json())
176
177
 
178
+ def get_html_widget(
179
+ self,
180
+ id: str,
181
+ content_type: str,
182
+ territory: str = "TW",
183
+ widget_lang: str = "EN",
184
+ autoplay: bool = False,
185
+ loop: bool = False,
186
+ ) -> str:
187
+ """
188
+ Return KKBOX HTML widget for "Playlist", "Album" or "Song". It does not return actual HTML code,
189
+ the URL returned can be used in an HTML ``iframe`` with the help of ``src`` attribute.
190
+
191
+ Parameters
192
+ ----------
193
+ id : str
194
+ ``ID`` of playlist, album or track.
195
+ content_type : str
196
+ Content type can be ``playlist``, ``album`` or ``song``.
197
+ territory : str, optional
198
+ Territory code, i.e. "TW", "HK", "JP", "SG", "MY", by default "TW"
199
+ widget_lang : str, optional
200
+ The display language of the widget. Can be "TC", "SC", "JA", "EN", "MS", by default "EN"
201
+ autoplay : bool, optional
202
+ Whether to start playing music automatically in widget, by default False
203
+ loop : bool, optional
204
+ Repeat/loop song(s), by default False
205
+
206
+ Returns
207
+ -------
208
+ str
209
+ KKBOX HTML widget URL.
210
+ """
211
+ valid_content_types = ["playlist", "album", "song"]
212
+ valid_widget_langs = ["TC", "SC", "JA", "EN", "MS"]
213
+ if content_type not in valid_content_types:
214
+ raise InvalidValueException(
215
+ f"`content_type` must be one of these: {valid_content_types} !"
216
+ )
217
+
218
+ if territory not in self.valid_territories:
219
+ raise InvalidValueException(
220
+ f"`territory` must be one of these: {self.valid_territories} !"
221
+ )
222
+
223
+ if widget_lang not in valid_widget_langs:
224
+ raise InvalidValueException(
225
+ f"`widget_lang` must be one of these: {valid_widget_langs} !"
226
+ )
227
+
228
+ return f"https://widget.kkbox.com/v1/?id={id}&type={content_type}&terr={territory}&lang={widget_lang}&autoplay={autoplay}&loop={loop}"
229
+
177
230
  def _find_music_info(
178
231
  self, artist: str, song: str, response_json: dict
179
232
  ) -> Optional[MusicInfo]:
yutipy/spotify.py CHANGED
@@ -69,7 +69,7 @@ class Spotify:
69
69
 
70
70
  def __exit__(self, exc_type, exc_value, exc_traceback):
71
71
  """Exits the runtime context related to this object."""
72
- self._close_session()
72
+ self.close_session()
73
73
 
74
74
  def close_session(self) -> None:
75
75
  """Closes the current session."""
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: yutipy
3
- Version: 1.1.0
3
+ Version: 1.2.1
4
4
  Summary: A simple package for retrieving music information from various music platforms APIs.
5
5
  Author: Cheap Nightbot
6
6
  Author-email: Cheap Nightbot <hi@cheapnightbot.slmail.me>
@@ -54,6 +54,7 @@ Requires-Dist: requests==2.32.3
54
54
  Requires-Dist: ytmusicapi==1.10.1
55
55
  Provides-Extra: dev
56
56
  Requires-Dist: pytest; extra == "dev"
57
+ Dynamic: license-file
57
58
 
58
59
  <p align="center">
59
60
  <img src="https://raw.githubusercontent.com/CheapNightbot/yutipy/main/docs/_static/yutipy_header.png" alt="yutipy" />
@@ -0,0 +1,15 @@
1
+ yutipy/__init__.py,sha256=t0w-pRLjIGD3UtDyd-JpeL-RrMona7YTV_0lZCpGLEc,232
2
+ yutipy/deezer.py,sha256=W2ayzb3SpYzxUuTHrRkYyZbpQ2u9xh-b2IvVNfQNNdc,8640
3
+ yutipy/exceptions.py,sha256=4L0Oe1PwFP34LoFTy-Fruipk7uB-JkaackRmkjlaZJU,1138
4
+ yutipy/itunes.py,sha256=1ZpZOpsL1dc7W2lLd5qMqV-YD3TGl9pPJxXJa7rTSYA,5842
5
+ yutipy/kkbox.py,sha256=9sz8eb-pu-47DTP_4kgackX1ZLijnCnz7q_1M8BqLWo,12185
6
+ yutipy/models.py,sha256=RnfWjoNO1UoNsRvNRYd-4TpkU-4jHKu5t394vIqOOgw,1360
7
+ yutipy/musicyt.py,sha256=kvRYuhlNVuvy-WahJq895T3JAzmGTTiKB89r_uTMTAI,7155
8
+ yutipy/spotify.py,sha256=Oaktvdz7gLe2_PaktOmjlc8QpfhZWkmQnIZDmwoXlRE,13608
9
+ yutipy/utils/__init__.py,sha256=7UFcFZ7fBtNXOTngjnRD3MeobT3x5UT2Gag94TXVgLk,169
10
+ yutipy/utils/cheap_utils.py,sha256=LIuEHib_97NuLahXxdHJUD9v-ccXNUc3NrLYk8EQ52A,1652
11
+ yutipy-1.2.1.dist-info/licenses/LICENSE,sha256=_89JsS2QnBG8tAb5-VWbJDj_uJ002zPJAYBJJdh3DPY,1071
12
+ yutipy-1.2.1.dist-info/METADATA,sha256=yQvCQXgno1e179XkSR9lk7uLwITYElbmkrpTIRCjKFM,6489
13
+ yutipy-1.2.1.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
14
+ yutipy-1.2.1.dist-info/top_level.txt,sha256=t2A5V2_mUcfnHkbCy6tAQlb3909jDYU5GQgXtA4756I,7
15
+ yutipy-1.2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (78.0.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,15 +0,0 @@
1
- yutipy/__init__.py,sha256=t0w-pRLjIGD3UtDyd-JpeL-RrMona7YTV_0lZCpGLEc,232
2
- yutipy/deezer.py,sha256=TbPk6f1ytrtk9GHXOoRZ948fcgOi0619-rQC9xfTYu0,8641
3
- yutipy/exceptions.py,sha256=4L0Oe1PwFP34LoFTy-Fruipk7uB-JkaackRmkjlaZJU,1138
4
- yutipy/itunes.py,sha256=NhrllA3U0PUY3dNoMyiG1oZuyvdMQKYRBHzYSkt8ikM,5843
5
- yutipy/kkbox.py,sha256=l-I1FZjKzLLqjN0hO2hvz6AdNuYvD1B4XI36m3sWmfM,10123
6
- yutipy/models.py,sha256=RnfWjoNO1UoNsRvNRYd-4TpkU-4jHKu5t394vIqOOgw,1360
7
- yutipy/musicyt.py,sha256=kvRYuhlNVuvy-WahJq895T3JAzmGTTiKB89r_uTMTAI,7155
8
- yutipy/spotify.py,sha256=CZA9XF0EV5wSrLrN9cURtiFKSEHsIvqVlXLKkvb4JEM,13609
9
- yutipy/utils/__init__.py,sha256=7UFcFZ7fBtNXOTngjnRD3MeobT3x5UT2Gag94TXVgLk,169
10
- yutipy/utils/cheap_utils.py,sha256=LIuEHib_97NuLahXxdHJUD9v-ccXNUc3NrLYk8EQ52A,1652
11
- yutipy-1.1.0.dist-info/LICENSE,sha256=_89JsS2QnBG8tAb5-VWbJDj_uJ002zPJAYBJJdh3DPY,1071
12
- yutipy-1.1.0.dist-info/METADATA,sha256=2EY4cfuWnLA1fH4E1G1qp8x3o53M8bzAYSX6QPdxAms,6467
13
- yutipy-1.1.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
14
- yutipy-1.1.0.dist-info/top_level.txt,sha256=t2A5V2_mUcfnHkbCy6tAQlb3909jDYU5GQgXtA4756I,7
15
- yutipy-1.1.0.dist-info/RECORD,,