Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cfp: Add Video download url #1768

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions apps/api/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ def _require_video_api_key(func):
@wraps(func)
def wrapper(*args, **kwargs):
auth_header = request.headers.get("authorization", None)
if not auth_header or not auth_header.startswith("Bearer "):
if not auth_header:
abort(401)

if auth_header.startswith("bearer "):
bearer_token = auth_header.removeprefix("bearer ")
Copy link
Member

@marksteward marksteward Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contents of the Authorization header is case-sensitive, so "bearer" should be wrong. Can you include a comment to explain why this is needed? (So we can tidy it up when it's no longer the case.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it because I wasted 5 minutes scratching my head why my curl request was giving a 401 ;-)

I went looking for consensus online, always a mistake.. honestly, it seems like a bit of a mess: https://sgeb.io/posts/fix-go-oauth2-case-sensitive-bearer-auth-headers/

Given we're not implementing oauth here I figured it was a convenience and didn't worry about it too much.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, fair, # make it easier with curl would be fine then

elif auth_header.startswith("Bearer "):
bearer_token = auth_header.removeprefix("Bearer ")
else:
abort(401)

bearer_token = auth_header.removeprefix("Bearer ")
if not compare_digest(bearer_token, app.config["VIDEO_API_KEY"]):
abort(401)

Expand All @@ -46,6 +52,7 @@ def patch(self, proposal_id):
"thumbnail_url",
"c3voc_url",
"video_recording_lost",
"video_download_url",
}
if set(payload.keys()) - ALLOWED_ATTRIBUTES:
abort(400)
Expand All @@ -60,10 +67,7 @@ def patch(self, proposal_id):
return {
"id": proposal.id,
"slug": proposal.slug,
"youtube_url": proposal.youtube_url,
"thumbnail_url": proposal.thumbnail_url,
"c3voc_url": proposal.c3voc_url,
"video_recording_lost": proposal.video_recording_lost,
**{a: getattr(proposal, a) for a in ALLOWED_ATTRIBUTES}
}


Expand Down
2 changes: 2 additions & 0 deletions apps/schedule/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def _get_proposal_dict(proposal: Proposal, favourites_ids):
video_res["youtube"] = proposal.youtube_url
if proposal.thumbnail_url:
video_res["preview_image"] = proposal.thumbnail_url
if proposal.video_download_url:
video_res["video_download_url"] = proposal.video_download_url
video_res["recording_lost"] = proposal.video_recording_lost
if video_res:
res["video"] = video_res
Expand Down
3 changes: 3 additions & 0 deletions apps/schedule/schedule_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ def add_event(room, event):

_add_sub_with_text(event_node, "subtitle", "")

if vdu := event.get("video", {}).get("video_download_url"):
_add_sub_with_text(event_node, "video_download_url", vdu)

add_persons(event_node, event)
add_recording(event_node, event)

Expand Down
28 changes: 28 additions & 0 deletions migrations/versions/a666c0f102e2_add_video_download_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""add video download url

Revision ID: a666c0f102e2
Revises: 7249f66e2ae0
Create Date: 2024-08-26 23:39:26.318321

"""

# revision identifiers, used by Alembic.
revision = 'a666c0f102e2'
down_revision = '7249f66e2ae0'

from alembic import op
import sqlalchemy as sa


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('proposal', sa.Column('video_download_url', sa.String(), nullable=True))
op.add_column('proposal_version', sa.Column('video_download_url', sa.String(), autoincrement=False, nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('proposal_version', 'video_download_url')
op.drop_column('proposal', 'video_download_url')
# ### end Alembic commands ###
7 changes: 7 additions & 0 deletions models/cfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,13 @@ class Proposal(BaseModel):
youtube_url = db.Column(db.String)
thumbnail_url = db.Column(db.String)
video_recording_lost = db.Column(db.Boolean, default=False)
video_download_url = db.Column(
db.String,
doc="""
Canonical, potentially ephemeral source for the video recording.
Used to automate release of videos to other platforms, in particular media.ccc.de.
""",
)

type_might_require_ticket = False
tickets = db.relationship("EventTicket", backref="proposal")
Expand Down