Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 516a85d

Browse files
Add Lyric Image support
1 parent 93c04b0 commit 516a85d

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

docs/api.rst

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Translate
3030
Results
3131
-------
3232

33+
.. autoclass:: openrobot.api_wrapper.LyricImages()
34+
:members:
35+
:inherited-members:
36+
3337
.. autoclass:: openrobot.api_wrapper.LyricResult()
3438
:members:
3539
:inherited-members:

examples/async/lyrics.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66

77
lyrics.title # Never gonna give you up
88
lyrics.artist # ...
9-
lyrics.lyric
9+
lyrics.lyric # ...
10+
lyrics.images.background # https://cdn.openrobot.xyz/lyrics/...
11+
lyrics.images.track # https://cdn.openrobot.xyz/lyrics/...

examples/sync/lyrics.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66

77
lyrics.title # Never gonna give you up
88
lyrics.artist # ...
9-
lyrics.lyric
9+
lyrics.lyric # ...
10+
lyrics.images.background # https://cdn.openrobot.xyz/lyrics/...
11+
lyrics.images.track # https://cdn.openrobot.xyz/lyrics/...

openrobot/api_wrapper/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
from . import _async, _sync, translate, results, error
88

9-
__version__ = '0.2.0'
9+
__version__ = '0.2.1'

openrobot/api_wrapper/results.py

+20
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ class OpenRobotAPIBaseResult:
1313
def __init__(self, js):
1414
self.raw = js
1515

16+
class LyricImages:
17+
"""
18+
The Lyric's Track Images.
19+
20+
Attributes
21+
----------
22+
background: Optional[:class:`str`]
23+
The background image of the track.
24+
track: Optional[:class:`str`]
25+
The track image.
26+
"""
27+
28+
def __init__(self, js):
29+
self.background: typing.Optional[str] = js.get('background')
30+
self.track: typing.Optional[str] = js.get('track')
31+
1632
class LyricResult(OpenRobotAPIBaseResult):
1733
"""
1834
The result of the /api/lyrics endpoint.
@@ -25,6 +41,8 @@ class LyricResult(OpenRobotAPIBaseResult):
2541
The artist of the song.
2642
lyrics :class:`str`
2743
The lyrics of the song.
44+
images: :class:`LyricImages`
45+
Represents The Lyric's Track Images.
2846
"""
2947

3048
def __init__(self, js):
@@ -34,6 +52,8 @@ def __init__(self, js):
3452
self.artist: str = js['artist']
3553
self.lyrics: str = js['lyrics']
3654

55+
self.images = LyricImages(js.get('images', {}))
56+
3757
class NSFWLabel:
3858
"""
3959
NSFW Label.

0 commit comments

Comments
 (0)