Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend_common_py
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
videoag
backend_common_py
Commits
fc812c4e
Commit
fc812c4e
authored
8 months ago
by
Simon Künzel
Browse files
Options
Downloads
Patches
Plain Diff
Add more fields to target media
parent
55260ba9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/videoag_common/objects/medium.py
+78
-26
78 additions, 26 deletions
src/videoag_common/objects/medium.py
with
78 additions
and
26 deletions
src/videoag_common/objects/medium.py
+
78
−
26
View file @
fc812c4e
...
@@ -67,6 +67,21 @@ class SourceMedium(DeletableApiObject, Base):
...
@@ -67,6 +67,21 @@ class SourceMedium(DeletableApiObject, Base):
data_notes
=
"
Only calculated once this is sorted
"
data_notes
=
"
Only calculated once this is sorted
"
)
)
)
)
file_size
:
Mapped
[
int
]
=
api_mapped
(
mapped_column
(
sql
.
types
.
BigInteger
,
nullable
=
True
),
ApiIntegerField
(
include_in_data
=
True
,
data_notes
=
"
Only calculated once this is sorted
"
)
)
metadata
:
Mapped
[
JsonTypes
]
=
api_mapped
(
mapped_column
(
sql
.
JSON
,
nullable
=
True
),
ApiDataField
(
include_in_data
=
True
,
# See source file sorter for contents
data_notes
=
"
Only calculated once this is sorted. There are no guarantees regarding the content
"
)
)
tag
:
Mapped
[
str
]
=
mapped_column
(
String
(
collation
=
STRING_COLLATION
),
nullable
=
True
)
tag
:
Mapped
[
str
]
=
mapped_column
(
String
(
collation
=
STRING_COLLATION
),
nullable
=
True
)
lecture
:
Mapped
[
Lecture
]
=
relationship
(
lecture
:
Mapped
[
Lecture
]
=
relationship
(
...
@@ -105,7 +120,6 @@ class TargetMedium(DeletableApiObject, Base):
...
@@ -105,7 +120,6 @@ class TargetMedium(DeletableApiObject, Base):
producer_job_id
:
Mapped
[
int
]
=
mapped_column
(
ForeignKey
(
"
job.id
"
),
nullable
=
True
)
producer_job_id
:
Mapped
[
int
]
=
mapped_column
(
ForeignKey
(
"
job.id
"
),
nullable
=
True
)
is_produced
:
Mapped
[
bool
]
=
mapped_column
(
nullable
=
False
,
default
=
False
)
is_produced
:
Mapped
[
bool
]
=
mapped_column
(
nullable
=
False
,
default
=
False
)
to_be_replaced
:
Mapped
[
bool
]
=
mapped_column
(
nullable
=
False
,
default
=
False
)
to_be_replaced
:
Mapped
[
bool
]
=
mapped_column
(
nullable
=
False
,
default
=
False
)
file_path
:
Mapped
[
str
]
=
mapped_column
(
String
(
collation
=
STRING_COLLATION
),
nullable
=
True
,
index
=
True
)
# TODO move?
type
:
Mapped
[
TargetMediumType
]
=
api_mapped
(
type
:
Mapped
[
TargetMediumType
]
=
api_mapped
(
mapped_column
(
_TARGET_MEDIUM_TYPE_ENUM
,
nullable
=
False
),
mapped_column
(
_TARGET_MEDIUM_TYPE_ENUM
,
nullable
=
False
),
ApiEnumField
(
ApiEnumField
(
...
@@ -127,19 +141,6 @@ class TargetMedium(DeletableApiObject, Base):
...
@@ -127,19 +141,6 @@ class TargetMedium(DeletableApiObject, Base):
lazy
=
"
raise_on_sql
"
lazy
=
"
raise_on_sql
"
)
)
@api_include_in_data
(
type_id
=
"
string
"
,
data_notes
=
"
URL to the mediums
'
s file (Maybe with a redirect)
"
)
def
url
(
self
)
->
str
:
# This is not too nice and only works from the API, but we need to access the API config
import
api
return
f
"
{
api
.
config
[
'
API_BASE_URL
'
]
}
/resources/target_medium/
{
self
.
id
}
"
def
get_default_file_path_no_ending
(
self
):
# TODO path
return
f
"
{
self
.
process_target_id
}
.
{
self
.
id
}
"
@hybrid_method
@hybrid_method
def
is_active
(
self
,
usable_check
:
bool
=
True
,
from_lecture
:
bool
=
False
,
from_publish_medium
:
bool
=
False
,
**
kwargs
):
def
is_active
(
self
,
usable_check
:
bool
=
True
,
from_lecture
:
bool
=
False
,
from_publish_medium
:
bool
=
False
,
**
kwargs
):
cond
=
super
().
is_active
(
**
kwargs
)
cond
=
super
().
is_active
(
**
kwargs
)
...
@@ -194,32 +195,61 @@ class TargetMedium(DeletableApiObject, Base):
...
@@ -194,32 +195,61 @@ class TargetMedium(DeletableApiObject, Base):
return
options
return
options
# Note that this usually also includes audio
class
FileTargetMedium
(
TargetMedium
):
class
PlainVideoTargetMedium
(
TargetMedium
):
file_path
:
Mapped
[
str
]
=
mapped_column
(
String
(
collation
=
STRING_COLLATION
),
nullable
=
True
,
index
=
True
)
# TODO move?
__tablename__
=
None
# Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__
=
{
@api_include_in_data
(
"
polymorphic_identity
"
:
TargetMediumType
.
PLAIN_VIDEO
type_id
=
"
string
"
,
}
data_notes
=
"
URL to the mediums
'
s file (Maybe with a redirect)
"
)
def
url
(
self
)
->
str
:
# This is not too nice and only works from the API, but we need to access the API config
import
api
return
f
"
{
api
.
config
[
'
API_BASE_URL
'
]
}
/resources/target_medium/
{
self
.
id
}
"
vertical_resolution
:
Mapped
[
int
]
=
api_mapped
(
def
get_default_file_path_no_ending
(
self
):
# TODO path
return
f
"
{
self
.
process_target_id
}
.
{
self
.
id
}
"
class
SingleAudioContainingMedium
(
TargetMedium
):
audio_sample_rate
:
Mapped
[
int
]
=
api_mapped
(
mapped_column
(
nullable
=
True
),
ApiIntegerField
(
include_in_data
=
True
,
help
=
"
In Hz
"
)
)
audio_channel_count
:
Mapped
[
int
]
=
api_mapped
(
mapped_column
(
nullable
=
True
),
ApiIntegerField
(
include_in_data
=
True
)
)
class
SingleVideoContainingMedium
(
TargetMedium
):
video_vertical_resolution
:
Mapped
[
int
]
=
api_mapped
(
mapped_column
(
nullable
=
True
),
mapped_column
(
nullable
=
True
),
ApiIntegerField
(
ApiIntegerField
(
include_in_data
=
True
include_in_data
=
True
)
)
)
)
horizontal_resolution
:
Mapped
[
int
]
=
api_mapped
(
video_
horizontal_resolution
:
Mapped
[
int
]
=
api_mapped
(
mapped_column
(
nullable
=
True
),
mapped_column
(
nullable
=
True
),
ApiIntegerField
(
ApiIntegerField
(
include_in_data
=
True
include_in_data
=
True
)
)
)
)
frame_rate_numerator
:
Mapped
[
int
]
=
api_mapped
(
video_
frame_rate_numerator
:
Mapped
[
int
]
=
api_mapped
(
mapped_column
(
nullable
=
True
),
mapped_column
(
nullable
=
True
),
ApiIntegerField
(
ApiIntegerField
(
include_in_data
=
True
include_in_data
=
True
)
)
)
)
frame_rate_denominator
:
Mapped
[
int
]
=
api_mapped
(
video_
frame_rate_denominator
:
Mapped
[
int
]
=
api_mapped
(
mapped_column
(
nullable
=
True
),
mapped_column
(
nullable
=
True
),
ApiIntegerField
(
ApiIntegerField
(
include_in_data
=
True
include_in_data
=
True
...
@@ -227,14 +257,36 @@ class PlainVideoTargetMedium(TargetMedium):
...
@@ -227,14 +257,36 @@ class PlainVideoTargetMedium(TargetMedium):
)
)
class
PlainAudioTargetMedium
(
TargetMedium
):
class
PlainVideoTargetMedium
(
FileTargetMedium
,
SingleVideoContainingMedium
,
SingleAudioContainingMedium
):
__tablename__
=
None
# Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__
=
{
"
polymorphic_identity
"
:
TargetMediumType
.
PLAIN_VIDEO
}
duration_sec
:
Mapped
[
int
]
=
api_mapped
(
mapped_column
(
nullable
=
True
),
ApiIntegerField
(
include_in_data
=
True
)
)
# TODO check vars not null (except audio)
class
PlainAudioTargetMedium
(
FileTargetMedium
,
SingleAudioContainingMedium
):
__tablename__
=
None
# Prevent our own base from adding a table name. This should be a single-table inheritance
__tablename__
=
None
# Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__
=
{
__mapper_args__
=
{
"
polymorphic_identity
"
:
TargetMediumType
.
PLAIN_AUDIO
"
polymorphic_identity
"
:
TargetMediumType
.
PLAIN_AUDIO
}
}
duration_sec
:
Mapped
[
int
]
=
api_mapped
(
mapped_column
(
nullable
=
True
),
ApiIntegerField
(
include_in_data
=
True
)
)
class
ThumbnailTargetMedium
(
TargetMedium
):
class
ThumbnailTargetMedium
(
File
TargetMedium
):
__tablename__
=
None
# Prevent our own base from adding a table name. This should be a single-table inheritance
__tablename__
=
None
# Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__
=
{
__mapper_args__
=
{
"
polymorphic_identity
"
:
TargetMediumType
.
THUMBNAIL
"
polymorphic_identity
"
:
TargetMediumType
.
THUMBNAIL
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment