Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
metadata-downloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaflix
metadata-downloader
Commits
a2eeab1e
Verified
Commit
a2eeab1e
authored
4 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Implement previews
parent
dc83bf03
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/directory_walker.js
+6
-1
6 additions, 1 deletion
src/directory_walker.js
src/metadata_loader.js
+24
-11
24 additions, 11 deletions
src/metadata_loader.js
src/model.js
+3
-0
3 additions, 0 deletions
src/model.js
src/storage.js
+26
-2
26 additions, 2 deletions
src/storage.js
with
59 additions
and
14 deletions
src/directory_walker.js
+
6
−
1
View file @
a2eeab1e
...
...
@@ -114,6 +114,10 @@ class FileManager {
fileName
.
endsWith
(
"
.vtt
"
)
)
const
previewFilePath
=
path
.
join
(
base
,
"
spritesheets
"
,
"
preview.vtt
"
);
const
previewFileExists
=
(
await
fsPromises
.
stat
(
previewFilePath
)).
isFile
();
const
previewFile
=
previewFileExists
?
previewFilePath
:
null
;
const
mediaFiles
=
dashManifest
?
[
dashManifest
]
:
files
.
filter
(
fileName
=>
fileName
.
endsWith
(
"
.mp4
"
)
||
fileName
.
endsWith
(
"
.webm
"
)
||
...
...
@@ -138,7 +142,8 @@ class FileManager {
src
:
encodePath
(
path
.
relative
(
this
.
basePath
,
path
.
join
(
base
,
"
subtitles
"
,
name
)))
}
}),
media
:
media
preview
:
previewFile
!==
null
?
encodePath
(
path
.
relative
(
this
.
basePath
,
previewFile
))
:
null
,
media
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/metadata_loader.js
+
24
−
11
View file @
a2eeab1e
...
...
@@ -14,6 +14,7 @@ import {
TitleImage
,
TitleMedia
,
TitleName
,
TitlePreview
,
TitleRating
,
TitleSubtitles
}
from
"
./model
"
;
...
...
@@ -237,7 +238,7 @@ class MetadataLoader {
await
originalTitleDescription
.
setTitle
(
episodeTitle
.
id
,
{
save
:
false
});
await
originalTitleDescription
.
save
();
for
(
let
el
of
tmdbTranslations
.
translations
)
{
if
(
el
.
data
.
overview
)
{
if
(
el
.
data
.
overview
&&
el
.
data
.
overview
.
trim
()
!==
""
)
{
const
titleDescription
=
await
TitleDescription
.
build
({
region
:
el
.
iso_3166_1
,
languages
:
el
.
iso_639_1
?
el
.
iso_639_1
.
split
(
"
,
"
)
:
[],
...
...
@@ -408,11 +409,23 @@ class MetadataLoader {
}
async
processMediaMetadata
(
title
,
media
)
{
await
TitleMedia
.
destroy
({
await
Promise
.
all
([
TitleMedia
.
destroy
({
where
:
{
title_id
:
title
.
id
,
}
}),
TitleSubtitles
.
destroy
({
where
:
{
title_id
:
title
.
id
,
}
}),
TitlePreview
.
destroy
({
where
:
{
title_id
:
title
.
id
,
}
})
]);
for
(
let
format
of
media
.
media
)
{
const
titleMedia
=
await
TitleMedia
.
build
({
mime
:
format
.
container
,
...
...
@@ -423,11 +436,6 @@ class MetadataLoader {
await
titleMedia
.
setTitle
(
title
.
id
,
{
save
:
false
});
await
titleMedia
.
save
();
}
await
TitleSubtitles
.
destroy
({
where
:
{
title_id
:
title
.
id
,
}
})
for
(
let
subtitle
of
media
.
subtitles
)
{
const
titleSubtitles
=
await
TitleSubtitles
.
build
({
language
:
subtitle
.
language
,
...
...
@@ -439,6 +447,11 @@ class MetadataLoader {
await
titleSubtitles
.
setTitle
(
title
.
id
,
{
save
:
false
});
await
titleSubtitles
.
save
();
}
const
titlePreview
=
await
TitlePreview
.
build
({
src
:
media
.
preview
,
})
await
titlePreview
.
setTitle
(
title
.
id
,
{
save
:
false
});
await
titlePreview
.
save
();
}
async
loadEpisodeMetadata
(
ids
,
episodeIdentifier
)
{
...
...
This diff is collapsed.
Click to expand it.
src/model.js
+
3
−
0
View file @
a2eeab1e
...
...
@@ -35,3 +35,6 @@ export class TitleRating extends sequelize.Model {
export
class
TitleSubtitles
extends
sequelize
.
Model
{
}
export
class
TitlePreview
extends
sequelize
.
Model
{
}
This diff is collapsed.
Click to expand it.
src/storage.js
+
26
−
2
View file @
a2eeab1e
...
...
@@ -10,8 +10,9 @@ import {
TitleImage
,
TitleMedia
,
TitleName
,
TitlePreview
,
TitleRating
,
TitleSubtitles
TitleSubtitles
,
}
from
"
./model
"
;
class
Backend
{
...
...
@@ -399,13 +400,36 @@ class Backend {
}
});
Title
.
hasMany
(
TitleSubtitles
);
TitlePreview
.
init
({
id
:
{
type
:
sequelize
.
DataTypes
.
UUID
,
defaultValue
:
sequelize
.
DataTypes
.
UUIDV4
,
allowNull
:
false
,
primaryKey
:
true
},
src
:
{
type
:
sequelize
.
DataTypes
.
TEXT
,
allowNull
:
true
,
},
},
{
sequelize
:
this
.
db
,
underscored
:
true
,
modelName
:
'
title_preview
'
,
indexes
:
[]
});
TitlePreview
.
belongsTo
(
Title
,
{
foreignKey
:
{
allowNull
:
false
,
}
});
Title
.
hasOne
(
TitlePreview
);
}
async
sync
()
{
await
Promise
.
all
([
Genre
.
sync
(),
Person
.
sync
(),
Title
.
sync
(),
TitleCast
.
sync
(),
TitleDescription
.
sync
(),
TitleEpisode
.
sync
(),
TitleGenre
.
sync
(),
TitleImage
.
sync
(),
TitleMedia
.
sync
(),
TitleName
.
sync
(),
TitleRating
.
sync
(),
TitleSubtitles
.
sync
(),
TitleMedia
.
sync
(),
TitleName
.
sync
(),
TitleRating
.
sync
(),
TitleSubtitles
.
sync
(),
TitlePreview
.
sync
(),
]);
}
...
...
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