forked from CERNDocumentServer/cds-videos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo.py
More file actions
162 lines (137 loc) · 4.79 KB
/
video.py
File metadata and controls
162 lines (137 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# -*- coding: utf-8 -*-
#
# This file is part of CERN Document Server.
# Copyright (C) 2016, 2017, 2018 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02D111-1307, USA.
"""Video JSON schema."""
from invenio_jsonschemas import current_jsonschemas
from marshmallow import Schema, fields, pre_load, post_load
from marshmallow_utils.fields import SanitizedHTML
from ....deposit.api import Video
from ..fields.datetime import DateString
from .common import (
AccessSchema,
BucketSchema,
ContributorSchema,
DepositSchema,
ExternalSystemIdentifiersField,
KeywordsSchema,
LicenseSchema,
OaiSchema,
RelatedLinksSchema,
StrictKeysSchema,
TitleSchema,
TranslationsSchema,
)
from .doi import DOI
class _CDSSSchema(Schema):
"""CDS private metadata."""
state = fields.Raw()
extracted_metadata = fields.Raw()
modified_by = fields.Int()
@pre_load
def remove_legacy_fields(self, data, **kwargs):
"""Remove legacy fields."""
data.pop("current_user_mail", None)
return data
class VideoDepositSchema(DepositSchema):
"""Project Deposit Schema."""
id = fields.Str(required=True)
class CopyrightSchema(StrictKeysSchema):
"""Copyright schema."""
holder = fields.Str()
url = fields.Str()
year = fields.Str()
class VideoFileSchema(StrictKeysSchema):
"""Video file schema."""
bitrate = fields.Str()
bucket = fields.Str()
category = fields.Str()
checksum = fields.Str()
height = fields.Str()
key = fields.Str()
previewer = fields.Str()
quality = fields.Str()
size = fields.Integer()
thumbnail = fields.Str()
type = fields.Str()
version_id = fields.Str()
width = fields.Str()
class AcceleratorExperimentSchema(StrictKeysSchema):
"""Field accelerator_experiment."""
project = fields.Str()
study = fields.Str()
experiment = fields.Str()
accelerator = fields.Str()
facility = fields.Str()
class PhysicalMediumSchema(StrictKeysSchema):
"""Field physical medium."""
arrangement = fields.Str()
bar_code = fields.Str()
camera = fields.Str()
copy_number = fields.Str()
internal_note = fields.Str()
location = fields.Str()
medium_standard = fields.Str()
note = fields.Str()
sequence_number = fields.List(fields.Str, many=True)
shelf = fields.Str()
class VideoSchema(StrictKeysSchema):
"""Video schema."""
_access = fields.Nested(AccessSchema)
_buckets = fields.Nested(BucketSchema)
_cds = fields.Nested(_CDSSSchema, required=True)
_deposit = fields.Nested(VideoDepositSchema, required=True)
_oai = fields.Nested(OaiSchema)
_project_id = fields.Str()
accelerator_experiment = fields.Nested(AcceleratorExperimentSchema)
agency_code = fields.Str()
category = fields.Str()
contributors = fields.Nested(ContributorSchema, many=True, required=True)
copyright = fields.Nested(CopyrightSchema)
date = DateString(required=True)
description = SanitizedHTML(required=True)
doi = DOI()
duration = fields.Str()
external_system_identifiers = fields.Nested(
ExternalSystemIdentifiersField, many=True
)
featured = fields.Boolean()
internal_note = fields.Str()
internal_categories = fields.Raw()
Press = fields.List(fields.Str, many=True)
keywords = fields.Nested(KeywordsSchema, many=True)
language = fields.Str()
license = fields.Nested(LicenseSchema, many=True)
note = fields.Str()
publication_date = fields.Str()
recid = fields.Number()
related_links = fields.Nested(RelatedLinksSchema, many=True)
report_number = fields.List(fields.Str, many=True)
schema = fields.Str(attribute="$schema", data_key="$schema")
title = fields.Nested(TitleSchema, required=True)
translations = fields.Nested(TranslationsSchema, many=True)
type = fields.Str()
vr = fields.Boolean()
# Preservation fields
location = fields.Str()
original_source = fields.Str()
physical_medium = fields.Nested(PhysicalMediumSchema, many=True)
@post_load(pass_many=False)
def post_load(self, data, **kwargs):
"""Post load."""
data["$schema"] = current_jsonschemas.path_to_url(Video._schema)
return data