Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
AURA
tank
Commits
4878ce98
Commit
4878ce98
authored
6 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
added parser for file metadata
parent
a807a135
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
store/files.go
+6
-0
6 additions, 0 deletions
store/files.go
store/files_metadata.go
+72
-0
72 additions, 0 deletions
store/files_metadata.go
with
78 additions
and
0 deletions
store/files.go
+
6
−
0
View file @
4878ce98
...
...
@@ -94,6 +94,12 @@ func (st *Store) UpdateFileImportState(group string, id uint64, state ImportStat
is
[
"source__import__state"
]
=
state
is
[
"source__import__success"
]
=
success
// TODO: this should probably be called more explicit?
if
state
==
ImportDone
{
// TODO: handle returned error...
st
.
SyncFileMetadata
(
group
,
id
)
}
if
err
:=
st
.
db
.
Model
(
&
file
)
.
Where
(
"group_name = ?"
,
group
)
.
Update
(
is
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
store/files_metadata.go
0 → 100644
+
72
−
0
View file @
4878ce98
//
// tank
//
// Import and Playlist Daemon for autoradio project
//
//
// Copyright (C) 2017-2018 Christian Pointner <equinox@helsinki.at>
//
// This file is part of tank.
//
// tank 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 3 of the License, or
// any later version.
//
// tank 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 tank. If not, see <http://www.gnu.org/licenses/>.
//
package
store
import
(
"bytes"
"context"
"encoding/json"
"fmt"
"os/exec"
"time"
)
type
ffprobeFormat
struct
{
NumStreams
uint
`json:"nb_streams"`
FormatName
string
`json:"format_name"`
DurationSec
string
`json:"duration"`
Size
string
`json:"size"`
BitRate
string
`json:"bit_rate"`
Tags
map
[
string
]
string
`json:"tags"`
}
type
ffprobeOutput
struct
{
Format
ffprobeFormat
`json:"format"`
}
func
(
st
*
Store
)
SyncFileMetadata
(
group
string
,
id
uint64
)
(
err
error
)
{
filename
:=
st
.
GetFilePath
(
group
,
id
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Second
)
defer
cancel
()
// cmd := exec.CommandContext(ctx, "ffprobe", "-hide_banner", "-print_format", "json", "-show_format", filename)
cmd
:=
exec
.
CommandContext
(
ctx
,
"ffprobe"
,
"-print_format"
,
"json"
,
"-show_format"
,
filename
)
var
stdout
,
stderr
bytes
.
Buffer
cmd
.
Stdout
=
&
stdout
cmd
.
Stderr
=
&
stderr
// TODO: handle stderr...
if
err
=
cmd
.
Run
();
err
!=
nil
{
return
}
var
output
ffprobeOutput
jd
:=
json
.
NewDecoder
(
&
stdout
)
if
err
:=
jd
.
Decode
(
&
output
);
err
!=
nil
{
return
err
}
// TODO: store metadata in database
fmt
.
Printf
(
"ffprobe output: %+v"
,
output
)
return
}
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