42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
__author__ = 'dev'
|
|
import json
|
|
from utilities.serializer import Serializer
|
|
from config.config import Config
|
|
|
|
class PodcastSerializer(Serializer):
|
|
|
|
def __init__(self, episode_file_type):
|
|
self.episode_file_type = episode_file_type
|
|
|
|
def serialize(self, dict_object):
|
|
"""
|
|
method convert i dict to a string.
|
|
this method should be override by any subclasses
|
|
:param dict_object: object wich his to bee convert to a string
|
|
:return: rhe string reprasention of the dict_object
|
|
"""
|
|
assert isinstance(dict_object, dict)
|
|
|
|
episodeList = []
|
|
|
|
for episode in dict_object["entries"]:
|
|
filelink = ""
|
|
for links in episode["links"]:
|
|
if links["type"] == self.episode_file_type:
|
|
filelink = links["href"]
|
|
|
|
tempepisode = {
|
|
"title": episode["title"],
|
|
"subtitle": episode["subtitle"],
|
|
"filelink": filelink
|
|
}
|
|
episodeList.append(tempepisode)
|
|
|
|
tempdict = {
|
|
"title": dict_object["feed"]["title"],
|
|
"subtitle": dict_object["feed"]["subtitle"],
|
|
"summary": dict_object["feed"]["summary"],
|
|
"episodes": episodeList
|
|
}
|
|
|
|
return tempdict |