Skip to content

Commit

Permalink
added /show/schedule_by:
Browse files Browse the repository at this point in the history
this returns shows by day with the latest already premiered episode
updated swagger docs
  • Loading branch information
tuz666 committed Mar 4, 2022
1 parent 1df647b commit 009c762
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 10 deletions.
28 changes: 20 additions & 8 deletions arcsi/api/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ def make_show(self, data, **kwargs):
show_schema = ShowDetailsSchema()
show_archive_schema = ShowDetailsSchema(only=("id", "active", "name", "description", "cover_image_url",
"day", "start", "end", "frequency", "language",
"archive_lahmastore_base_url", "items"))
"playlist_name", "archive_lahmastore_base_url", "items"))
show_partial_schema = ShowDetailsSchema(partial=True)
shows_schema = ShowDetailsSchema(many=True)
shows_schedule_schema = ShowDetailsSchema(many=True, exclude=("items",))
shows_schedule2_schema = ShowDetailsSchema(many=True,
shows_schedule_by_schema = ShowDetailsSchema(many=True,
only=("id", "active", "name", "description", "cover_image_url",
"day", "start", "end", "frequency", "language",
"archive_lahmastore_base_url", "items"))
"playlist_name", "archive_lahmastore_base_url", "items"))
shows_archive_schema = ShowDetailsSchema(many=True,
only=("id", "active", "name", "description", "cover_image_url",
"playlist_name", "archive_lahmastore_base_url"))
Expand All @@ -94,15 +94,27 @@ def list_shows():

@arcsi.route("/show/schedule", methods=["GET"])
def list_shows_for_schedule():
return shows_schedule_schema.dumps(get_shows())
do = DoArchive()
shows = Show.query.filter(Show.active == True).all()
for show in shows:
if show.cover_image_url:
show.cover_image_url = do.download(
show.archive_lahmastore_base_url, show.cover_image_url
)
return shows_schedule_schema.dumps(shows)

@arcsi.route("/show/schedule2", methods=["GET"])
def list_shows_for_schedule2():
@arcsi.route("/show/schedule_by", methods=["GET"])
def list_shows_for_schedule_by():
do = DoArchive()
shows = Show.query.all()
shows_json = shows_schedule2_schema.dump(shows)
day = request.args.get('day', 1, type=int)
shows = Show.query.filter(Show.day == day and Show.active == True).all()
shows_json = shows_schedule_by_schema.dump(shows)
# iterate through shows
for show_json in shows_json:
if show_json["cover_image_url"]:
show_json["cover_image_url"] = do.download(
show_json["archive_lahmastore_base_url"], show_json["cover_image_url"]
)
if show_json["items"]:
latest_item_found = False
# iterate through show's items
Expand Down
23 changes: 22 additions & 1 deletion arcsi/static/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"name": {
"type": "string",
"example": "show-name"
},
"archive_lahmastore_base_url": {
"type": "string",
"example": "show-archive_lahmastore_base_url"
}
}
},
Expand All @@ -50,6 +54,10 @@
"type": "string",
"example": "item-name"
},
"name_slug": {
"type": "string",
"example": "item-name"
},
"description": {
"type": "string",
"example": "item-description"
Expand Down Expand Up @@ -337,6 +345,10 @@
"end": {
"type": "string"
},
"id": {
"type": "integer",
"format": "int32"
},
"day": {
"type": "integer",
"format": "int32"
Expand All @@ -348,7 +360,7 @@
"items": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/ItemBasicRequest"
"$ref": "#/components/schemas/item"
}
}
}
Expand Down Expand Up @@ -484,6 +496,9 @@
"name": {
"type": "string"
},
"name_slug": {
"type": "string"
},
"description": {
"type": "string"
},
Expand Down Expand Up @@ -538,6 +553,9 @@
"name": {
"type": "string"
},
"name_slug": {
"type": "string"
},
"description": {
"type": "string"
},
Expand Down Expand Up @@ -583,6 +601,9 @@
"name": {
"type": "string"
},
"name_slug": {
"type": "string"
},
"description": {
"type": "string"
},
Expand Down
34 changes: 33 additions & 1 deletion arcsi/static/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,38 @@
}
}
},
"/show/schedule_by?day={day}": {
"get": {
"tags": [
"Show Requests for frontend"
],
"summary": "Return Shows for Ananasz Home and Schedule Page",
"parameters": [
{
"in": "path",
"name": "day",
"required": true,
"description": "day, default: 1",
"type": "number"
}
],
"produces": [
"text/html"
],
"responses": {
"200": {
"description": "OK",
"content": {
"text/html": {
"schema": {
"$ref": "component.json#/components/schemas/ShowScheduleResponseBodies"
}
}
}
}
}
}
},
"/show/{show_slug}/page": {
"get": {
"tags": [
Expand Down Expand Up @@ -483,7 +515,7 @@
"in": "path",
"name": "episode_slug",
"required": true,
"description": "Item.play_file_name + '.mp3'",
"description": "normalize(Item.name) --> name_slug",
"type": "string"
}
],
Expand Down

0 comments on commit 009c762

Please sign in to comment.