yutipy 1.4.1__py3-none-any.whl → 1.4.2__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 +14 -4
- yutipy/spotify.py +2 -2
- yutipy/utils/cheap_utils.py +16 -2
- {yutipy-1.4.1.dist-info → yutipy-1.4.2.dist-info}/METADATA +1 -1
- {yutipy-1.4.1.dist-info → yutipy-1.4.2.dist-info}/RECORD +8 -8
- {yutipy-1.4.1.dist-info → yutipy-1.4.2.dist-info}/WHEEL +0 -0
- {yutipy-1.4.1.dist-info → yutipy-1.4.2.dist-info}/licenses/LICENSE +0 -0
- {yutipy-1.4.1.dist-info → yutipy-1.4.2.dist-info}/top_level.txt +0 -0
yutipy/itunes.py
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from pprint import pprint
|
|
3
|
-
from typing import
|
|
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
|
|
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
|
-
|
|
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("
|
|
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"],
|
yutipy/utils/cheap_utils.py
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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,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=
|
|
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=
|
|
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=
|
|
11
|
+
yutipy/utils/cheap_utils.py,sha256=ttNu566ybTQ3BzQ2trBgpvpNthB6Da-KnkBbFiK3pw4,5282
|
|
12
12
|
yutipy/utils/logger.py,sha256=2_b2FlDwUVpdPdqiwweR8Xr2tZOq0qGUGcekC5lXq2M,130
|
|
13
|
-
yutipy-1.4.
|
|
14
|
-
yutipy-1.4.
|
|
15
|
-
yutipy-1.4.
|
|
16
|
-
yutipy-1.4.
|
|
17
|
-
yutipy-1.4.
|
|
13
|
+
yutipy-1.4.2.dist-info/licenses/LICENSE,sha256=_89JsS2QnBG8tAb5-VWbJDj_uJ002zPJAYBJJdh3DPY,1071
|
|
14
|
+
yutipy-1.4.2.dist-info/METADATA,sha256=nxBwtRJFWpM7gsgH9-RZIP239hna-PirfWJ2WIBxXB4,6495
|
|
15
|
+
yutipy-1.4.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
16
|
+
yutipy-1.4.2.dist-info/top_level.txt,sha256=t2A5V2_mUcfnHkbCy6tAQlb3909jDYU5GQgXtA4756I,7
|
|
17
|
+
yutipy-1.4.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|