switch showtime format

This commit is contained in:
Your Name 2023-06-07 04:14:38 -04:00 committed by Henri Dickson
parent 2044d811b1
commit e02f74e3ae
7 changed files with 52 additions and 27 deletions

View file

@ -94,9 +94,25 @@ class Movie(Item):
blank=True,
default=list,
schema={
"type": "array",
"items": {"type": "dict", "additionalProperties": True, "keys": []},
}, # TODO fix it as simple dict...
"type": "list",
"items": {
"type": "dict",
"additionalProperties": False,
"keys": {
"time": {
"type": "string",
"title": _("日期"),
"placeholder": _("必填"),
},
"region": {
"type": "string",
"title": _("区域或类型"),
"placeholder": _("如中国大陆或柏林电影节"),
},
},
"required": ["time"],
},
},
)
site = jsondata.URLField(
verbose_name=_("官方网站"), blank=True, default="", max_length=200

View file

@ -101,7 +101,12 @@ class DoubanMovie(AbstractSite):
else:
time = st.split("(")[0]
region = st.split("(")[1][0:-1]
showtime.append({time: region})
showtime.append(
{
"region": region,
"time": time,
}
)
else:
showtime = None

View file

@ -64,7 +64,7 @@ class TMDB_Movie(AbstractSite):
)
imdb_code = res_data["external_ids"]["imdb_id"]
showtime = (
[{res_data["first_air_date"]: "首播日期"}]
[{"time": res_data["first_air_date"], "region": "首播日期"}]
if res_data["first_air_date"]
else None
)
@ -78,7 +78,7 @@ class TMDB_Movie(AbstractSite):
else None
)
showtime = (
[{res_data["release_date"]: "发布日期"}]
[{"time": res_data["release_date"], "region": "发布日期"}]
if res_data["release_date"]
else None
)
@ -198,7 +198,7 @@ class TMDB_TV(AbstractSite):
)
imdb_code = res_data["external_ids"]["imdb_id"]
showtime = (
[{res_data["first_air_date"]: "首播日期"}]
[{"time": res_data["first_air_date"], "region": "首播日期"}]
if res_data["first_air_date"]
else None
)
@ -212,7 +212,7 @@ class TMDB_TV(AbstractSite):
else None
)
showtime = (
[{res_data["release_date"]: "发布日期"}]
[{"time": res_data["release_date"], "region": "发布日期"}]
if res_data["release_date"]
else None
)

View file

@ -138,11 +138,9 @@
{% if item.showtime %}
{% trans '上映时间:' %}
{% for showtime in item.showtime %}
{% for time, region in showtime.items %}
<span>{{ time }}
{% if region != '' %}({{ region }}){% endif %}
</span>
{% endfor %}
<span>{{ showtime.time }}
{% if showtime.region %}({{ showtime.region }}){% endif %}
</span>
{% if not forloop.last %}/{% endif %}
{% endfor %}
{% endif %}

View file

@ -122,11 +122,9 @@
{% if item.showtime %}
{% trans '上映时间:' %}
{% for showtime in item.showtime %}
{% for time, region in showtime.items %}
<span>{{ time }}
{% if region != '' %}({{ region }}){% endif %}
</span>
{% endfor %}
<span>{{ showtime.time }}
{% if showtime.region %}({{ showtime.region }}){% endif %}
</span>
{% if not forloop.last %}/{% endif %}
{% endfor %}
{% endif %}

View file

@ -136,11 +136,9 @@
{% if item.showtime %}
{% trans '播出时间:' %}
{% for showtime in item.showtime %}
{% for time, region in showtime.items %}
<span>{{ time }}
{% if region != '' %}({{ region }}){% endif %}
</span>
{% endfor %}
<span>{{ showtime.time }}
{% if showtime.region %}({{ showtime.region }}){% endif %}
</span>
{% if not forloop.last %}/{% endif %}
{% endfor %}
{% endif %}

View file

@ -148,8 +148,13 @@ class TVShow(Item):
default=list,
schema={
"type": "array",
"items": {"type": "dict", "additionalProperties": True, "keys": []},
}, # TODO fix it as simple dict...
"items": {
"type": "dict",
"additionalProperties": False,
"keys": ["region", "time"],
"required": ["time"],
},
},
)
site = jsondata.URLField(
verbose_name=_("官方网站"), blank=True, default="", max_length=200
@ -284,8 +289,13 @@ class TVSeason(Item):
default=list,
schema={
"type": "array",
"items": {"type": "dict", "additionalProperties": True, "keys": []},
}, # TODO fix it as simple dict...
"items": {
"type": "dict",
"additionalProperties": False,
"keys": ["region", "time"],
"required": ["time"],
},
},
)
site = jsondata.URLField(
verbose_name=_("官方网站"), blank=True, default="", max_length=200