diff --git a/arcsi/api/item.py b/arcsi/api/item.py index 4fac4fa5..cef7497c 100644 --- a/arcsi/api/item.py +++ b/arcsi/api/item.py @@ -1,3 +1,4 @@ +from datetime import datetime, timedelta import json import os import requests @@ -9,6 +10,7 @@ from flask import flash, jsonify, make_response, request, send_file, url_for, redirect from flask import current_app as app from marshmallow import fields, post_load, Schema, ValidationError +from sqlalchemy import func from uuid import uuid4 @@ -17,10 +19,11 @@ broadcast_audio, dict_to_obj, media_path, + normalise, save_file, item_duplications_number ) -from arcsi.api import arcsi +from . import arcsi from arcsi.handler.upload import DoArchive from arcsi.model import db from arcsi.model.item import Item @@ -33,6 +36,7 @@ class ItemDetailsSchema(Schema): required=True ) # TODO value can't be 0 -- reserved for show itself name = fields.Str(required=True, min=1) + name_slug = fields.Str(dump_only=True) description = fields.Str() language = fields.Str(max=5) play_date = fields.Date(required=True) @@ -51,7 +55,7 @@ class ItemDetailsSchema(Schema): shows = fields.List( fields.Nested( "ShowDetailsSchema", - only=("id", "name"), + only=("id", "name", "archive_lahmastore_base_url"), ), required=True, ) @@ -62,14 +66,14 @@ def make_item(self, data, **kwargs): item_schema = ItemDetailsSchema() -item_archive_schema = ItemDetailsSchema(only = ("name", "number", "play_date", "language", - "description", "image_url", "play_file_name", "download_count")) -item_partial_schema = ItemDetailsSchema(partial=True,) -items_schema = ItemDetailsSchema(many=True) -items_archive_schema = ItemDetailsSchema(many=True, - only=("name", "description", - "play_date", "play_file_name", - "image_url", "download_count")) +item_archive_schema = ItemDetailsSchema( + only = ("id", "number", "name", "name_slug", "description", "language", "play_date", + "image_url", "play_file_name", "archived", "download_count", "shows")) +item_partial_schema = ItemDetailsSchema(partial = True,) +items_schema = ItemDetailsSchema(many = True) +items_archive_schema = ItemDetailsSchema(many = True, + only = ("id", "number", "name", "name_slug", "description", "language", "play_date", + "image_url", "play_file_name", "archived", "download_count", "shows")) headers = {"Content-Type": "application/json"} @@ -84,20 +88,25 @@ def list_items(): item.image_url = do.download( item.shows[0].archive_lahmastore_base_url, item.image_url ) + item.name_slug=normalise(item.name) return items_schema.dumps(items) -@arcsi.route("/item/latest/", methods=["GET"]) + +@arcsi.route("/item/latest", methods=["GET"]) def list_items_latest(): do = DoArchive() page = request.args.get('page', 1, type=int) size = request.args.get('size', 12, type=int) - items = Item.query.order_by(Item.play_date.desc()).paginate( - page, size, False) + items = Item.query.filter(Item.play_date < datetime.today() - timedelta(days=1) + ).filter(Item.archived == True + ).order_by(Item.play_date.desc() + ).paginate(page, size, False) for item in items.items: if item.image_url: item.image_url = do.download( item.shows[0].archive_lahmastore_base_url, item.image_url ) + item.name_slug=normalise(item.name) return items_archive_schema.dumps(items.items) @@ -111,6 +120,7 @@ def view_item(id): item.image_url = do.download( item.shows[0].archive_lahmastore_base_url, item.image_url ) + item.name_slug=normalise(item.name) return item_schema.dump(item) else: return make_response("Item not found", 404, headers) @@ -454,4 +464,23 @@ def edit_item(id): return make_response( jsonify(item_partial_schema.dump(item)), 200, headers ) - return "Some error happened, check server logs for details. Note that your media may have been uploaded (to DO and/or Azurcast)." \ No newline at end of file + return "Some error happened, check server logs for details. Note that your media may have been uploaded (to DO and/or Azurcast)." + + +@arcsi.route("/item/search", methods=["GET"]) +def search_item(): + do = DoArchive() + page = request.args.get('page', 1, type=int) + size = request.args.get('size', 12, type=int) + param = request.args.get('param', "", type=str) + items = Item.query.filter(func.lower(Item.name).contains(func.lower(param)) | + func.lower(Item.description).contains(func.lower(param)) + ).filter(Item.play_date < datetime.today() - timedelta(days=1) + ).order_by(Item.play_date.desc()).paginate(page, size, False) + for item in items.items: + if item.image_url: + item.image_url = do.download( + item.shows[0].archive_lahmastore_base_url, item.image_url + ) + item.name_slug=normalise(item.name) + return items_schema.dumps(items.items) diff --git a/arcsi/api/show.py b/arcsi/api/show.py index bb893909..276b8bd9 100644 --- a/arcsi/api/show.py +++ b/arcsi/api/show.py @@ -7,10 +7,11 @@ from flask import flash, jsonify, make_response, request, url_for from flask import current_app as app from marshmallow import fields, post_load, Schema, ValidationError +from sqlalchemy import false, func from werkzeug import secure_filename -from .utils import archive, get_shows, save_file, slug, sort_for -from arcsi.api import arcsi +from .utils import archive, get_shows, save_file, slug, sort_for, normalise +from . import arcsi from arcsi.handler.upload import DoArchive from arcsi.model import db from arcsi.model.show import Show @@ -20,7 +21,6 @@ class ShowDetailsSchema(Schema): id = fields.Int() - name = fields.Str(required=True) active = fields.Boolean(required=True) name = fields.Str(required=True) description = fields.Str(required=True) @@ -44,6 +44,7 @@ class ShowDetailsSchema(Schema): "description", "number", "name", + "name_slug", "play_file_name", "play_date", "image_url", @@ -66,25 +67,20 @@ def make_show(self, data, **kwargs): return Show(**data) -show_schema = ShowDetailsSchema(only=("id", "name", "active", "description", - "cover_image_url", "playlist_name", "items", - "language", "frequency", "week", "day", "start", - "end", "archive_lahmastore", "archive_lahmastore_base_url", - "archive_mixcloud", "users")) -show_archive_schema = ShowDetailsSchema(only=("name", "cover_image_url", - "day", "start", "end", - "frequency", "language", - "active", "description", - "items")) +show_schema = ShowDetailsSchema() +show_archive_schema = ShowDetailsSchema(only=("id", "active", "name", "description", "cover_image_url", + "day", "start", "end", "frequency", "language", + "playlist_name", "archive_lahmastore_base_url", "items")) show_partial_schema = ShowDetailsSchema(partial=True) shows_schema = ShowDetailsSchema(many=True) -shows_schedule_schema = ShowDetailsSchema(many=True, - only=("active", "name", "cover_image_url", - "day", "start", "end", - "description", "archive_lahmastore_base_url")) +shows_schedule_schema = ShowDetailsSchema(many=True, exclude=("items",)) +shows_schedule_by_schema = ShowDetailsSchema(many=True, + only=("id", "active", "name", "description", "cover_image_url", + "day", "start", "end", "frequency", "language", + "playlist_name", "archive_lahmastore_base_url", "items")) shows_archive_schema = ShowDetailsSchema(many=True, - only=("active", "name", "cover_image_url", - "description", "archive_lahmastore_base_url")) + only=("id", "active", "name", "description", "cover_image_url", + "playlist_name", "archive_lahmastore_base_url")) headers = {"Content-Type": "application/json"} @@ -95,15 +91,60 @@ def make_show(self, data, **kwargs): def list_shows(): return shows_schema.dumps(get_shows()) + +@arcsi.route("/show/all_without_items", methods=["GET"]) +def list_shows_without_items(): + return shows_schedule_schema.dumps(get_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/schedule_by", methods=["GET"]) +def list_shows_for_schedule_by(): + do = DoArchive() + 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 + for item in show_json["items"]: + # search for the first one which is archived & already aired + if (latest_item_found == False and + item["archived"] == True and + ((datetime.strptime(item["play_date"], "%Y-%m-%d") + timedelta(days=1)) < datetime.today())): + latest_item_found = True + item["image_url"] = do.download( + show_json["archive_lahmastore_base_url"], item["image_url"] + ) + item["name_slug"] = normalise(item["name"]) + show_json["items"] = item + # if there is no archived show return empty array + if (latest_item_found == False): + show_json["items"] = [] + return json.dumps(shows_json) + # We are gonna use this on the new page as the show/all @arcsi.route("/show/list", methods=["GET"]) def list_shows_page(): return shows_archive_schema.dumps(get_shows()) + # TODO /item//add route so that each upload has unique id to begin with # no need for different methods for `POST` & `PUT` @arcsi.route("/show/add", methods=["POST"]) @@ -261,6 +302,7 @@ def edit_show(id): jsonify(show_partial_schema.dump(show)), 200, headers ) + @arcsi.route("show/", methods=["GET"]) def view_show(id): do = DoArchive() @@ -276,11 +318,14 @@ def view_show(id): serial_show = show_schema.dump(show) date_desc_episodes = sort_for(serial_show["items"], "play_date", "desc") serial_show["items"] = date_desc_episodes + for item in serial_show["items"]: + item["name_slug"] = normalise(item["name"]) return serial_show else: return make_response("Show not found", 404, headers) + # We use this route on the legacy front-end show page @arcsi.route("show//archive", methods=["GET"]) def view_show_archive(show_slug): @@ -300,6 +345,7 @@ def view_show_archive(show_slug): show_item["image_url"] = do.download( show.archive_lahmastore_base_url, show_item["image_url"] ) + show_item["name_slug"]=normalise(show_item["name"]) return json.dumps(show_items) else: return make_response("Show not found", 404, headers) @@ -313,23 +359,60 @@ def view_show_archive(show_slug): # This will be the one that we are gonna use at the new page @arcsi.route("show//page", methods=["GET"]) def view_show_page(show_slug): + do = DoArchive() show_query = Show.query.filter_by(archive_lahmastore_base_url=show_slug) show = show_query.first() if show: # subquery = session.query(Item.id).filter(blabla -timedelta(day=1)).all().subquery() # query = session.query(Show).filter_by(blabla).(Item.id.in_(subquery)) - show.items.filter(Item.play_date < datetime.today() - timedelta(days=1)).all() - return show_archive_schema.dump(show) + if show.cover_image_url: + show.cover_image_url = do.download( + show.archive_lahmastore_base_url, show.cover_image_url + ) + serial_show = show_archive_schema.dump(show) + show_items = [ + show_item + for show_item in serial_show["items"] + if datetime.strptime(show_item.get("play_date"), "%Y-%m-%d") + + timedelta(days=1) + < datetime.today() + ] + serial_show["items"]=show_items + for item in serial_show["items"]: + item["image_url"] = do.download( + show.archive_lahmastore_base_url, item["image_url"] + ) + item["name_slug"]=normalise(item["name"]) + return serial_show else: return make_response("Show not found", 404, headers) -@arcsi.route("show//episode/", methods=["GET"]) -def view_episode_archive(show_slug, episode_slug): - episode_slug = episode_slug + ".mp3" +@arcsi.route("show//item/", methods=["GET"]) +def view_episode_archive(show_slug, item_slug): + do = DoArchive() show_query = Show.query.filter_by(archive_lahmastore_base_url=show_slug) show = show_query.first_or_404() - for i in show.items: - if i.play_file_name == episode_slug: - return item_archive_schema.dump(i) - return make_response("Episode not found", 404, headers) \ No newline at end of file + for item in show.items: + if (normalise(item.name) == item_slug): + item.image_url = do.download( + show.archive_lahmastore_base_url, item.image_url + ) + item.name_slug=item_slug + return item_archive_schema.dump(item) + return make_response("Episode not found", 404, headers) + + +@arcsi.route("/show/search", methods=["GET"]) +def search_show(): + do = DoArchive() + page = request.args.get('page', 1, type=int) + size = request.args.get('size', 12, type=int) + param = request.args.get('param', "", type=str) + shows = Show.query.filter(func.lower(Show.name).contains(func.lower(param)) | func.lower(Show.description).contains(func.lower(param))).paginate(page, size, False) + for show in shows.items: + 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.items) \ No newline at end of file diff --git a/arcsi/model/show.py b/arcsi/model/show.py index ea18e09a..72ea9d6b 100644 --- a/arcsi/model/show.py +++ b/arcsi/model/show.py @@ -25,6 +25,7 @@ class Show(db.Model): "Item", secondary=items_shows, backref=db.backref("shows"), + order_by="Item.play_date.desc()", lazy="dynamic", # TODO why is this not working? see item.shows assignment in api/item cascade_backrefs=False, diff --git a/arcsi/static/component.json b/arcsi/static/component.json index 873af246..ae2efcab 100644 --- a/arcsi/static/component.json +++ b/arcsi/static/component.json @@ -37,25 +37,27 @@ "name": { "type": "string", "example": "show-name" + }, + "archive_lahmastore_base_url": { + "type": "string", + "example": "show-archive_lahmastore_base_url" } } }, "item": { "properties": { - "id": { - "type": "integer", - "format": "int32", - "example": 1 - }, - "number": { - "type": "integer", - "format": "int32", - "example": 42 + "archived": { + "type": "boolean", + "example": true }, "name": { "type": "string", "example": "item-name" }, + "name_slug": { + "type": "string", + "example": "item-name" + }, "description": { "type": "string", "example": "item-description" @@ -69,9 +71,24 @@ "type": "string", "example": "item-image_url" }, - "archived": { - "type": "boolean", - "example": true + "play_file_name": { + "type": "string", + "example": "item-play_file_name" + }, + "id": { + "type": "integer", + "format": "int32", + "example": 1 + }, + "number": { + "type": "integer", + "format": "int32", + "example": 42 + }, + "download_count": { + "type": "integer", + "format": "int32", + "example": 420 } } }, @@ -139,37 +156,76 @@ "$ref": "#/components/schemas/UserRequest" } }, - "ShowScheduleRequest": { + "ShowResponseBody": { "type": "object", "properties": { "active": { "type": "boolean" }, + "archive_lahmastore": { + "type": "boolean" + }, + "archive_mixcloud": { + "type": "boolean" + }, "name": { "type": "string" }, - "cover_image_url": { + "description": { "type": "string" }, - "day": { - "type": "integer", - "format": "int32" + "language": { + "type": "string" }, - "start": { + "playlist_name": { "type": "string" }, - "end": { + "archive_lahmastore_base_url": { "type": "string" }, - "description": { + "archive_mixcloud_base_url": { "type": "string" }, - "archive_lahmastore_base_url": { + "cover_image_url": { + "type": "string" + }, + "start": { "type": "string" + }, + "end": { + "type": "string" + }, + "day": { + "type": "integer", + "format": "int32" + }, + "frequency": { + "type": "integer", + "format": "int32" + }, + "week": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "users": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/user" + } + }, + "items": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/item" + } } } }, - "ShowArchiveRequest": { + "ShowsPageResponseBody": { "type": "object", "properties": { "active": { @@ -178,80 +234,97 @@ "name": { "type": "string" }, - "cover_image_url": { + "description": { "type": "string" }, - "description": { + "playlist_name": { "type": "string" }, "archive_lahmastore_base_url": { "type": "string" + }, + "cover_image_url": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int32" } } }, - "ShowSubPageRequest": { + "ShowScheduleResponseBody": { "type": "object", "properties": { + "active": { + "type": "boolean" + }, + "archive_lahmastore": { + "type": "boolean" + }, + "archive_mixcloud": { + "type": "boolean" + }, "name": { "type": "string" }, - "cover_image_url": { + "description": { "type": "string" }, - "day": { - "type": "integer", - "format": "int32" - }, - "start": { + "language": { "type": "string" }, - "end": { + "playlist_name": { "type": "string" }, - "frequency": { - "type": "integer", - "format": "int32" - }, - "language": { + "archive_lahmastore_base_url": { "type": "string" }, - "active": { - "type": "boolean" + "archive_mixcloud_base_url": { + "type": "string" }, - "description": { + "cover_image_url": { "type": "string" }, - "archive_lahmastore_base_url": { + "start": { "type": "string" }, - "playlist_name": { + "end": { "type": "string" }, - "items": { + "day": { + "type": "integer", + "format": "int32" + }, + "frequency": { + "type": "integer", + "format": "int32" + }, + "week": { + "type": "integer", + "format": "int32" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "users": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ItemBasicRequest" + "$ref": "#/components/schemas/user" } } } }, - "ShowRequest": { + "ShowSubPageResponseBody": { "type": "object", "properties": { - "id": { - "type": "integer", - "format": "int32" - }, - "name": { - "type": "string" - }, "active": { "type": "boolean" }, - "description": { + "name": { "type": "string" }, - "cover_image_url": { + "description": { "type": "string" }, "language": { @@ -260,13 +333,11 @@ "playlist_name": { "type": "string" }, - "frequency": { - "type": "integer", - "format": "int32" + "archive_lahmastore_base_url": { + "type": "string" }, - "day": { - "type": "integer", - "format": "int32" + "cover_image_url": { + "type": "string" }, "start": { "type": "string" @@ -274,14 +345,17 @@ "end": { "type": "string" }, - "archive_lahmastore_base_url": { - "type": "string" + "id": { + "type": "integer", + "format": "int32" }, - "users": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/user" - } + "day": { + "type": "integer", + "format": "int32" + }, + "frequency": { + "type": "integer", + "format": "int32" }, "items": { "type": "object", @@ -291,25 +365,25 @@ } } }, - "ShowScheduleRequests": { + "ShowResponseBodies": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ShowScheduleRequest" + "$ref": "#/components/schemas/ShowResponseBody" } }, - "ShowArchiveRequests": { + "ShowsPageResponseBodies": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ShowArchiveRequest" + "$ref": "#/components/schemas/ShowsPageResponseBody" } }, - "ShowRequests": { + "ShowScheduleResponseBodies": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ShowRequest" + "$ref": "#/components/schemas/ShowScheduleResponseBody" } }, - "ShowRequestPostBody": { + "ShowRequestBody": { "type": "object", "properties": { "active": { @@ -398,17 +472,47 @@ "user_email": "arcsi@lahmacun.hu" } }, - "ItemArchiveRequest": { + "ItemResponseBody": { "type": "object", "properties": { + "live": { + "type":"boolean" + }, + "broadcast": { + "type":"boolean" + }, + "airing": { + "type":"boolean" + }, + "archived": { + "type":"boolean" + }, + "archive_lahmastore": { + "type":"boolean" + }, + "archive_mixcloud": { + "type":"boolean" + }, "name": { "type": "string" }, + "name_slug": { + "type": "string" + }, + "description": { + "type": "string" + }, + "language": { + "type": "string" + }, "play_date": { "type": "string", "format": "date" }, - "description": { + "archive_lahmastore_canonical_url": { + "type": "string" + }, + "archive_mixcloud_canonical_url": { "type": "string" }, "image_url": { @@ -417,6 +521,17 @@ "play_file_name": { "type": "string" }, + "uploader": { + "type": "string" + }, + "id": { + "type": "integer", + "format": "int32" + }, + "number": { + "type": "integer", + "format": "int32" + }, "download_count": { "type": "integer", "format": "int32" @@ -424,30 +539,32 @@ "shows": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ShowArchiveRequest" + "$ref": "#/components/schemas/show" } } } }, - "ItemSubPageRequest": { + "ItemArchiveResponseBody": { "type": "object", "properties": { + "archived": { + "type":"boolean" + }, "name": { "type": "string" }, - "number": { - "type": "integer", - "format": "int32" + "name_slug": { + "type": "string" }, - "play_date": { - "type": "string", - "format": "date" + "description": { + "type": "string" }, "language": { "type": "string" }, - "description": { - "type": "string" + "play_date": { + "type": "string", + "format": "date" }, "image_url": { "type": "string" @@ -455,56 +572,47 @@ "play_file_name": { "type": "string" }, - "download_count": { + "id": { "type": "integer", "format": "int32" - } - } - }, - "ItemBasicRequest": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "image_url": { - "type": "string" - }, - "play_date": { - "type": "string", - "format": "date" }, - "description": { - "type": "string" + "number": { + "type": "integer", + "format": "int32" }, "download_count": { "type": "integer", "format": "int32" }, - "play_file_name": { - "type": "string" + "shows": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/show" + } } } }, - "ItemRequest": { + "ItemSubPageResponseBody": { "type": "object", "properties": { + "archived": { + "type":"boolean" + }, "name": { "type": "string" }, - "number": { - "type": "integer", - "format": "int32" + "name_slug": { + "type": "string" }, - "play_date": { - "type": "string", - "format": "date" + "description": { + "type": "string" }, "language": { "type": "string" }, - "description": { - "type": "string" + "play_date": { + "type": "string", + "format": "date" }, "image_url": { "type": "string" @@ -512,52 +620,45 @@ "play_file_name": { "type": "string" }, - "download_count": { + "id": { "type": "integer", "format": "int32" }, - "live": { - "type":"boolean" - }, - "broadcast": { - "type":"boolean" + "number": { + "type": "integer", + "format": "int32" }, - "archive_lahmastore_base_url": { - "type": "string" + "download_count": { + "type": "integer", + "format": "int32" }, "shows": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ShowArchiveRequest" - } - }, - "users": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/user" + "$ref": "#/components/schemas/show" } } } }, - "ItemArchiveRequests": { + "ItemResponseBodies": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ItemBasicRequest" + "$ref": "#/components/schemas/ItemResponseBody" } }, - "ItemBasicRequests": { + "ItemArchiveResponseBodies": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ItemBasicRequest" + "$ref": "#/components/schemas/ItemArchiveResponseBody" } }, - "ItemRequests": { + "ShowNestedItemResponsebodies": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ItemRequest" + "$ref": "#/components/schemas/item" } }, - "ItemRequestPostBody": { + "ItemRequestBody": { "type": "object", "properties": { "number": { diff --git a/arcsi/static/doc.json b/arcsi/static/doc.json index db55037a..d16f9082 100644 --- a/arcsi/static/doc.json +++ b/arcsi/static/doc.json @@ -2,7 +2,7 @@ "openapi": "3.0.0", "info": { "description": "Arcsi API doc", - "version": "0.9.5", + "version": "0.9.7", "title": "Arcsi", "contact": { "email": "it@lahmacun.hu" @@ -19,16 +19,24 @@ ], "tags": [ { - "name": "User Request", - "description": "API for requesting and return User details" + "name": "Show Requests for frontend", + "description": "API for requesting and return Show details" }, { - "name": "Show Request", + "name": "Item Requests for frontend", + "description": "API for requesting and return Item details" + }, + { + "name": "Show Requests for Arcsi", "description": "API for requesting and return Show details" }, { - "name": "Item Request", + "name": "Item Requests for Arcsi", "description": "API for requesting and return Item details" + }, + { + "name": "User Request", + "description": "API for requesting and return User details" } ], "paths": { @@ -95,9 +103,9 @@ "/show/all": { "get": { "tags": [ - "Show Request" + "Show Requests for Arcsi" ], - "summary": "Return Shows for Arcsi Show Archive", + "summary": "Return all Shows for Arcsi's Shows Page", "produces": [ "text/html" ], @@ -107,7 +115,7 @@ "content": { "text/html": { "schema": { - "$ref": "component.json#/components/schemas/ShowRequests" + "$ref": "component.json#/components/schemas/ShowResponseBodies" } } } @@ -115,14 +123,23 @@ } } }, - "/show/schedule": { + "/show/{id}": { "get": { "tags": [ - "Show Request" + "Show Requests for Arcsi" + ], + "summary": "Return chosen Show for Arcsi's Show Subpage", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "Show.id", + "type": "string" + } ], - "summary": "Return Shows for Ananasz Home and Schedule Page", "produces": [ - "text/html" + "application/json" ], "responses": { "200": { @@ -130,10 +147,13 @@ "content": { "text/html": { "schema": { - "$ref": "component.json#/components/schemas/ShowScheduleRequests" + "$ref": "component.json#/components/schemas/ShowResponseBody" } } } + }, + "404": { + "description": "Show not found" } } } @@ -141,9 +161,9 @@ "/show/list": { "get": { "tags": [ - "Show Request" + "Show Requests for frontend" ], - "summary": "Return Shows for Ananasz Shows Page", + "summary": "Return all Shows for Ananasz's Shows Page", "produces": [ "text/html" ], @@ -153,7 +173,7 @@ "content": { "text/html": { "schema": { - "$ref": "component.json#/components/schemas/ShowArchiveRequests" + "$ref": "component.json#/components/schemas/ShowsPageResponseBodies" } } } @@ -161,23 +181,60 @@ } } }, - "/show/{id}": { + "/show/all_without_items": { + "get": { + "tags": [ + "Show Requests for frontend" + ], + "summary": "Return all Shows for Ananasz's Shows Page", + "produces": [ + "text/html" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/html": { + "schema": { + "$ref": "component.json#/components/schemas/ShowScheduleResponseBodies" + } + } + } + } + } + } + }, + "/show/search?size={size}&page={page}¶m={param}": { "get": { "tags": [ - "Show Request" + "Show Requests for frontend" ], - "summary": "Return Show for Arcsi Show Page", + "summary": "Return all searched Shows (their name or description contains the parameter)", "parameters": [ { "in": "path", - "name": "id", + "name": "size", "required": true, - "description": "Show.id", + "description": "page_size, default: 12", + "type": "string" + }, + { + "in": "path", + "name": "page", + "required": true, + "description": "page_number, default: 1", + "type": "string" + }, + { + "in": "path", + "name": "param", + "required": true, + "description": "search_parameter, default: 1", "type": "string" } ], "produces": [ - "application/json" + "text/html" ], "responses": { "200": { @@ -185,7 +242,7 @@ "content": { "text/html": { "schema": { - "$ref": "component.json#/components/schemas/ShowRequest" + "$ref": "component.json#/components/schemas/ShowResponseBodies" } } } @@ -193,19 +250,42 @@ } } }, - "/show/{show_slug}/archive": { + "/show/schedule": { "get": { "tags": [ - "Item Request" + "Show Requests for frontend" + ], + "summary": "Return all active Shows for Ananasz's Home and Schedule Page", + "produces": [ + "text/html" ], - "summary": "Return Items for old WP Show Page", + "responses": { + "200": { + "description": "OK", + "content": { + "text/html": { + "schema": { + "$ref": "component.json#/components/schemas/ShowScheduleResponseBodies" + } + } + } + } + } + } + }, + "/show/schedule_by?day={day}": { + "get": { + "tags": [ + "Show Requests for frontend" + ], + "summary": "Return all active Shows airing on the chosen day for Ananasz's Home and Schedule Page", "parameters": [ { "in": "path", - "name": "show_slug", + "name": "day", "required": true, - "description": "Show.archive_lahmastore_base_url", - "type": "string" + "description": "day, default: 1", + "type": "number" } ], "produces": [ @@ -217,13 +297,10 @@ "content": { "text/html": { "schema": { - "$ref": "component.json#/components/schemas/ItemBasicRequests" + "$ref": "component.json#/components/schemas/ShowScheduleResponseBodies" } } } - }, - "404": { - "description": "Show not found" } } } @@ -231,9 +308,9 @@ "/show/{show_slug}/page": { "get": { "tags": [ - "Show Request" + "Show Requests for frontend" ], - "summary": "Return Show for Ananasz Show Subpage", + "summary": "Return the chosen Show for Ananasz's Show Subpage", "parameters": [ { "in": "path", @@ -252,7 +329,7 @@ "content": { "text/html": { "schema": { - "$ref": "component.json#/components/schemas/ShowSubPageRequest" + "$ref": "component.json#/components/schemas/ShowSubPageResponseBody" } } } @@ -263,26 +340,44 @@ } } }, - "/show/{show_slug}/episode/{episode_slug}": { + "/item/all": { "get": { "tags": [ - "Item Request" + "Item Requests for Arcsi" ], - "summary": "Return Episode for Ananasz Episode Subpage", + "summary": "Return all Items for Arcsi's Items Page", + "produces": [ + "text/html" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/html": { + "schema": { + "$ref": "component.json#/components/schemas/ItemResponseBodies" + } + } + } + } + } + } + }, + "/item/{id}": { + "get": { + "tags": [ + "Item Requests for Arcsi" + ], + "summary": "Return the chosen Item for Arcsi's Item Subpage", "parameters": [ { "in": "path", - "name": "show_slug", - "required": true, - "description": "Show.archive_lahmastore_base_url", - "type": "string" - }, - { - "in": "path", - "name": "episode_slug", + "name": "id", "required": true, - "description": "Item.play_file_name + '.mp3'", - "type": "string" + "description": "Item Request ID", + "schema": { + "$ref": "component.json#/components/schemas/id" + } } ], "produces": [ @@ -294,23 +389,39 @@ "content": { "application/json": { "schema": { - "$ref": "component.json#/components/schemas/ItemSubPageRequest" + "$ref": "component.json#/components/schemas/ItemResponseBody" } } } }, "404": { - "description": "Episode not found" + "description": "Item not found" } } } }, - "/item/all": { + "/item/latest?size={size}&page={page}": { "get": { "tags": [ - "Item Request" + "Item Requests for frontend" + ], + "summary": "Return latest Items for Ananasz's Home and Archive Page", + "parameters": [ + { + "in": "path", + "name": "size", + "required": true, + "description": "page_size, default: 12", + "type": "string" + }, + { + "in": "path", + "name": "page", + "required": true, + "description": "page_number, default: 1", + "type": "string" + } ], - "summary": "Return Episodes for Arcsi Items Archive", "produces": [ "text/html" ], @@ -320,7 +431,7 @@ "content": { "text/html": { "schema": { - "$ref": "component.json#/components/schemas/ItemRequests" + "$ref": "component.json#/components/schemas/ItemArchiveResponseBodies" } } } @@ -328,12 +439,12 @@ } } }, - "/item/latest/?size={size}&?page={page}": { + "/item/search?size={size}&page={page}¶m={param}": { "get": { "tags": [ - "Item Request" + "Item Requests for frontend" ], - "summary": "Return Latest Episodes for Ananasz Home and Archive Page", + "summary": "Return all searched Items (their name or description contains the parameter)", "parameters": [ { "in": "path", @@ -348,6 +459,13 @@ "required": true, "description": "page_number, default: 1", "type": "string" + }, + { + "in": "path", + "name": "param", + "required": true, + "description": "search_parameter, default: 1", + "type": "string" } ], "produces": [ @@ -359,7 +477,7 @@ "content": { "text/html": { "schema": { - "$ref": "component.json#/components/schemas/ItemArchiveRequests" + "$ref": "component.json#/components/schemas/ItemResponseBodies" } } } @@ -367,64 +485,79 @@ } } }, - "/item/{id}": { + "/show/{show_slug}/archive": { "get": { "tags": [ - "Item Request" + "Item Requests for Arcsi" ], - "summary": "Return Episode for Arcsi Episode Page", + "summary": "Return all Items for the given Show (was used by the old WP Show Page)", "parameters": [ { "in": "path", - "name": "id", + "name": "show_slug", "required": true, - "description": "Item Request ID", - "schema": { - "$ref": "component.json#/components/schemas/id" - } + "description": "Show.archive_lahmastore_base_url", + "type": "string" } ], "produces": [ - "application/json" + "text/html" ], "responses": { "200": { "description": "OK", "content": { - "application/json": { + "text/html": { "schema": { - "$ref": "component.json#/components/schemas/ItemRequest" + "$ref": "component.json#/components/schemas/ShowNestedItemResponsebodies" } } } }, "404": { - "description": "Item not found" + "description": "Show not found" } } - }, - "delete": { + } + }, + "/show/{show_slug}/item/{episode_slug}": { + "get": { "tags": [ - "Item Request" + "Item Requests for frontend" ], - "summary": "Delete Item with given ID", + "summary": "Return Item for Ananasz's Episode Subpage", "parameters": [ { "in": "path", - "name": "id", + "name": "show_slug", "required": true, - "description": "Item Request ID", - "schema": { - "$ref": "component.json#/components/schemas/id" - } + "description": "Show.archive_lahmastore_base_url", + "type": "string" + }, + { + "in": "path", + "name": "episode_slug", + "required": true, + "description": "normalize(Item.name) --> name_slug", + "type": "string" } ], + "produces": [ + "application/json" + ], "responses": { "200": { - "description": "OK" + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "component.json#/components/schemas/ItemSubPageResponseBody" + } + } + } }, "404": { - "description": "URL not found" + "description": "Episode not found" } } } @@ -432,7 +565,7 @@ "/item/{id}/listen": { "get": { "tags": [ - "Item Request" + "Item Requests for Arcsi" ], "summary": "Listen Item with given ID", "parameters": [ @@ -467,7 +600,7 @@ "/item/{id}/download": { "get": { "tags": [ - "Item Request" + "Item Requests for Arcsi" ], "summary": "Download Item with given ID", "parameters": [