-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserializer.py
26 lines (23 loc) · 861 Bytes
/
serializer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from exceptions import NotFoundTrack
class Track:
def __init__(self, music):
self.music = music
try:
self.track = self.music['track']
self.title = self.track['title']
self.subtitle = self.track['subtitle']
try:
self.image = self.track['images']['coverarthq']
except:
self.image = 'image'
try:
self.test = self.track['sections'][-4]['text']
self.text = '\n'.join([str(elem) for elem in self.test])
except:
try:
self.test = self.track['sections'][-3]['text']
self.text = '\n'.join([str(elem) for elem in self.test])
except:
self.text = "test"
except KeyError:
raise NotFoundTrack