yutipy 1.4.1__py3-none-any.whl → 1.4.22__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/itunes.py CHANGED
@@ -1,17 +1,21 @@
1
1
  from datetime import datetime
2
2
  from pprint import pprint
3
- from typing import Optional, Dict
3
+ from typing import Dict, Optional
4
4
 
5
5
  import requests
6
6
 
7
7
  from yutipy.exceptions import (
8
8
  InvalidResponseException,
9
9
  InvalidValueException,
10
- NetworkException,
11
10
  ItunesException,
11
+ NetworkException,
12
12
  )
13
13
  from yutipy.models import MusicInfo
14
- from yutipy.utils.cheap_utils import are_strings_similar, is_valid_string
14
+ from yutipy.utils.cheap_utils import (
15
+ are_strings_similar,
16
+ guess_album_type,
17
+ is_valid_string,
18
+ )
15
19
 
16
20
 
17
21
  class Itunes:
@@ -180,7 +184,13 @@ class Itunes:
180
184
  album_title, album_type = result["collectionName"].split("-")
181
185
  return album_title.strip(), album_type.strip()
182
186
  except ValueError:
183
- return result["collectionName"], result["wrapperType"]
187
+ guess = guess_album_type(result.get("trackCount", 1))
188
+ guessed_right = are_strings_similar(
189
+ result.get("wrapperType", "x"), guess, use_translation=False
190
+ )
191
+ return result["collectionName"], (
192
+ result["wrapperType"] if guessed_right else guess
193
+ )
184
194
 
185
195
  def _format_release_date(self, release_date: str) -> str:
186
196
  """
yutipy/spotify.py CHANGED
@@ -16,8 +16,8 @@ from yutipy.exceptions import (
16
16
  )
17
17
  from yutipy.models import MusicInfo
18
18
  from yutipy.utils.cheap_utils import (
19
- guess_album_type,
20
19
  are_strings_similar,
20
+ guess_album_type,
21
21
  is_valid_string,
22
22
  separate_artists,
23
23
  )
@@ -459,7 +459,7 @@ class Spotify:
459
459
  return MusicInfo(
460
460
  album_art=album["images"][0]["url"],
461
461
  album_title=album["name"],
462
- album_type=album.get("alnum_type") if guessed_right else guess,
462
+ album_type=album.get("album_type") if guessed_right else guess,
463
463
  artists=", ".join(artists_name),
464
464
  genre=None,
465
465
  id=album["id"],
@@ -1,7 +1,10 @@
1
+ import pykakasi
1
2
  import requests
2
3
  from rapidfuzz import fuzz
3
4
  from rapidfuzz.utils import default_process
4
5
 
6
+ kakasi = pykakasi.kakasi()
7
+
5
8
 
6
9
  def translate_text(
7
10
  text: str,
@@ -72,18 +75,29 @@ def are_strings_similar(
72
75
  Returns:
73
76
  bool: True if the strings are similar, otherwise False.
74
77
  """
78
+
75
79
  if use_translation:
76
- str1 = (
80
+ translated_str1 = (
77
81
  translate_text(str1, session=translation_session)["destination-text"]
78
82
  if translation_session
79
83
  else translate_text(str1)["destination-text"]
80
84
  )
81
- str2 = (
85
+ translated_str2 = (
82
86
  translate_text(str2, session=translation_session)["destination-text"]
83
87
  if translation_session
84
88
  else translate_text(str2)["destination-text"]
85
89
  )
86
90
 
91
+ similarity_score = fuzz.WRatio(
92
+ translated_str1, translated_str2, processor=default_process
93
+ )
94
+ if similarity_score > threshold:
95
+ return True
96
+
97
+ # Use transliterated strings for comparison
98
+ str1 = "".join(item["hepburn"] for item in kakasi.convert(str1)) or str1
99
+ str2 = "".join(item["hepburn"] for item in kakasi.convert(str2)) or str2
100
+
87
101
  similarity_score = fuzz.WRatio(str1, str2, processor=default_process)
88
102
  return similarity_score > threshold
89
103
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yutipy
3
- Version: 1.4.1
3
+ Version: 1.4.22
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>
@@ -33,7 +33,7 @@ Project-URL: Repository, https://github.com/CheapNightbot/yutipy.git
33
33
  Project-URL: Issues, https://github.com/CheapNightbot/yutipy/issues
34
34
  Project-URL: Changelog, https://github.com/CheapNightbot/yutipy/blob/master/CHANGELOG.md
35
35
  Project-URL: funding, https://ko-fi.com/cheapnightbot
36
- Keywords: music,API,Deezer,iTunes,Spotify,YouTube Music,search,retrieve,information,yutify,KKBox
36
+ Keywords: music,API,Deezer,iTunes,KKBox,Spotify,YouTube Music,search,retrieve,information,yutify
37
37
  Classifier: Development Status :: 4 - Beta
38
38
  Classifier: Intended Audience :: Developers
39
39
  Classifier: Topic :: Software Development :: Libraries
@@ -48,6 +48,7 @@ Classifier: Operating System :: OS Independent
48
48
  Requires-Python: >=3.8
49
49
  Description-Content-Type: text/markdown
50
50
  License-File: LICENSE
51
+ Requires-Dist: pykakasi==2.3.0
51
52
  Requires-Dist: python-dotenv==1.0.1
52
53
  Requires-Dist: rapidfuzz==3.12.1
53
54
  Requires-Dist: requests==2.32.3
@@ -1,17 +1,17 @@
1
1
  yutipy/__init__.py,sha256=ucXbhRgNpLo-G0TeDGCaKyCK9Ftc13hUqB8POWdUY1c,327
2
2
  yutipy/deezer.py,sha256=cTQpnOgS81mUw_EJ0b2Z1r9CG9ircHCxl9vL-oAJ9Lg,9622
3
3
  yutipy/exceptions.py,sha256=4L0Oe1PwFP34LoFTy-Fruipk7uB-JkaackRmkjlaZJU,1138
4
- yutipy/itunes.py,sha256=9VOcIfjezj8WAVpsne9bbBPoIUbn0GO0UWrCrXzbrE4,6758
4
+ yutipy/itunes.py,sha256=SZOCShlIyutIWQ2KI9WLqxc4gN4Cu2gilqxYwuXugUU,7059
5
5
  yutipy/kkbox.py,sha256=V-A7nFa1oNrTBOEu7DFzMHAHFZ5cPz55GInEuYfTSfg,13466
6
6
  yutipy/models.py,sha256=si_qgaApAYDfSyE8cl_Yg4IfWOtxk1I5JCT8bZsmV4U,1931
7
7
  yutipy/musicyt.py,sha256=igqz99bJYGtUGyZAmEJoQbdGIF-1YFmeaV5HmlhwqkA,8441
8
- yutipy/spotify.py,sha256=462mHo2GCurRNb0RKxu2ZlbmX9ZggPg_ZHN7fb0p9t4,15620
8
+ yutipy/spotify.py,sha256=P-MCOny1ZXK75_jdQKRI_jgUrK7B9xbBFOvRu6NOjxk,15620
9
9
  yutipy/yutipy_music.py,sha256=I4581MvcTTclSwVtAfMEsOujxmhZzqKyG7eX8zuEsEY,6424
10
10
  yutipy/utils/__init__.py,sha256=o6lk01FHwhFmNHV0HjGG0qe2azTaQT_eviiLgNV5fHw,232
11
- yutipy/utils/cheap_utils.py,sha256=MChJ29x-yj_LrdJfWu7qQT3-gSHDdPyPEGo5ITfbJSI,4824
11
+ yutipy/utils/cheap_utils.py,sha256=ttNu566ybTQ3BzQ2trBgpvpNthB6Da-KnkBbFiK3pw4,5282
12
12
  yutipy/utils/logger.py,sha256=2_b2FlDwUVpdPdqiwweR8Xr2tZOq0qGUGcekC5lXq2M,130
13
- yutipy-1.4.1.dist-info/licenses/LICENSE,sha256=_89JsS2QnBG8tAb5-VWbJDj_uJ002zPJAYBJJdh3DPY,1071
14
- yutipy-1.4.1.dist-info/METADATA,sha256=-DlkGS8lGIpG7lSewxaOR6hxikj3VdfT1avz23o2YKM,6495
15
- yutipy-1.4.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
16
- yutipy-1.4.1.dist-info/top_level.txt,sha256=t2A5V2_mUcfnHkbCy6tAQlb3909jDYU5GQgXtA4756I,7
17
- yutipy-1.4.1.dist-info/RECORD,,
13
+ yutipy-1.4.22.dist-info/licenses/LICENSE,sha256=_89JsS2QnBG8tAb5-VWbJDj_uJ002zPJAYBJJdh3DPY,1071
14
+ yutipy-1.4.22.dist-info/METADATA,sha256=7MST1bW-oYnZA9bZzRFPyJvW9RI86Ck5c0MVeGhQ7U0,6527
15
+ yutipy-1.4.22.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
16
+ yutipy-1.4.22.dist-info/top_level.txt,sha256=t2A5V2_mUcfnHkbCy6tAQlb3909jDYU5GQgXtA4756I,7
17
+ yutipy-1.4.22.dist-info/RECORD,,