Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 62e3573

Browse files
committed
Merge remote-tracking branch 'origin/encoder-decoder' into encoder-decoder
1 parent 29bdab5 commit 62e3573

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/vsmetaCodec/vsmetaBase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def _writeGroup2(self):
202202
grp2_content.writeTag(self.TAG2_POSTER_DATA, self.b64encodeImage(image_bytes))
203203
grp2_content.writeTag(self.TAG2_POSTER_MD5, img_info.md5str)
204204

205-
if len(self.info.tvshowMetaJson) > 0:
205+
if self.info.tvshowMetaJson is not None and len(self.info.tvshowMetaJson) > 0:
206206
grp2_content.writeTag(self.TAG2_TVSHOW_META_JSON, self.info.tvshowMetaJson)
207207

208208
grp3_content = VsMetaBase._writeGroup3(self) # call the base-class implementation directly, because

src/vsmetaCodec/vsmetaCode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def readVsData(self) -> 'VsMetaCode':
7676

7777
def readImage(self) -> (bytes, bool):
7878
image_str = self._readData(self.readSpecialInt())
79-
last_char_is_newline = (image_str[-1] == b'\n')
79+
last_char_is_newline = (image_str[-1] == b'\n'[0]) # 10 represents '\n'
8080
return base64.decodebytes(image_str), last_char_is_newline
8181

8282
def dumpData(self, num_bytes: int) -> None:

src/vsmetaCodec/vsmetaInfo.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self):
4141
self.episodeLocked = True
4242

4343
self.chapterSummary = ""
44-
self.episodeMetaJson = "null" # Berfre: correct initialization for an 'empty json string'
44+
self.episodeMetaJson = "null" # VsMetaInfo internally stores serialized json string
4545
self.tmdbReference = {} # convenience dictionary to access tmdb-id and imdb-id
4646

4747
self.classification = ""
@@ -82,6 +82,17 @@ def episodeReleaseDate(self, release_date: str | date):
8282
def setEpisodeDate(self, episode_date: str | date):
8383
self.episodeReleaseDate = episode_date
8484

85+
@property
86+
def episodeMetaJson(self) -> str:
87+
return self._episodeMetaJson
88+
89+
@episodeMetaJson.setter
90+
def episodeMetaJson(self, meta_json: dict | str):
91+
if type(meta_json) is dict:
92+
self._episodeMetaJson = json.dumps(meta_json, separators=(',', ':'))
93+
elif type(meta_json) is str:
94+
self._episodeMetaJson = meta_json
95+
8596
@property
8697
def tvshowReleaseDate(self) -> date:
8798
return self._tvshowReleaseDate
@@ -100,6 +111,17 @@ def tvshowReleaseDate(self, release_date: str | date):
100111
def setShowDate(self, show_date: str | date):
101112
self.tvshowReleaseDate = show_date
102113

114+
@property
115+
def tvshowMetaJson(self) -> str:
116+
return self._tvshowMetaJson
117+
118+
@tvshowMetaJson.setter
119+
def tvshowMetaJson(self, meta_json: dict | str):
120+
if type(meta_json) is dict:
121+
self._tvshowMetaJson = json.dumps(meta_json, separators=(',', ':'))
122+
elif type(meta_json) is str:
123+
self._tvshowMetaJson = meta_json
124+
103125
@property
104126
def timestamp(self) -> int:
105127
return self._timestamp # timestamps are stored internally as integer without milliseconds

0 commit comments

Comments
 (0)