yutipy 1.1.0__py3-none-any.whl → 1.2.0__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/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."""
@@ -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]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: yutipy
3
- Version: 1.1.0
3
+ Version: 1.2.0
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>
@@ -2,14 +2,14 @@ yutipy/__init__.py,sha256=t0w-pRLjIGD3UtDyd-JpeL-RrMona7YTV_0lZCpGLEc,232
2
2
  yutipy/deezer.py,sha256=TbPk6f1ytrtk9GHXOoRZ948fcgOi0619-rQC9xfTYu0,8641
3
3
  yutipy/exceptions.py,sha256=4L0Oe1PwFP34LoFTy-Fruipk7uB-JkaackRmkjlaZJU,1138
4
4
  yutipy/itunes.py,sha256=NhrllA3U0PUY3dNoMyiG1oZuyvdMQKYRBHzYSkt8ikM,5843
5
- yutipy/kkbox.py,sha256=l-I1FZjKzLLqjN0hO2hvz6AdNuYvD1B4XI36m3sWmfM,10123
5
+ yutipy/kkbox.py,sha256=yuyEanxxOXsiL2ZTtJMraETQxDetWfUu9K8IULSKQrQ,12186
6
6
  yutipy/models.py,sha256=RnfWjoNO1UoNsRvNRYd-4TpkU-4jHKu5t394vIqOOgw,1360
7
7
  yutipy/musicyt.py,sha256=kvRYuhlNVuvy-WahJq895T3JAzmGTTiKB89r_uTMTAI,7155
8
8
  yutipy/spotify.py,sha256=CZA9XF0EV5wSrLrN9cURtiFKSEHsIvqVlXLKkvb4JEM,13609
9
9
  yutipy/utils/__init__.py,sha256=7UFcFZ7fBtNXOTngjnRD3MeobT3x5UT2Gag94TXVgLk,169
10
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,,
11
+ yutipy-1.2.0.dist-info/LICENSE,sha256=_89JsS2QnBG8tAb5-VWbJDj_uJ002zPJAYBJJdh3DPY,1071
12
+ yutipy-1.2.0.dist-info/METADATA,sha256=GZOfBMev_zfoZ2JWhFM60t85GkOU2rerxowo1CFqR4c,6467
13
+ yutipy-1.2.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
14
+ yutipy-1.2.0.dist-info/top_level.txt,sha256=t2A5V2_mUcfnHkbCy6tAQlb3909jDYU5GQgXtA4756I,7
15
+ yutipy-1.2.0.dist-info/RECORD,,
File without changes