Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
2219995c
Commit
2219995c
authored
Apr 15, 2015
by
Hugo Beauzée-Luyssen
Browse files
Perform the supported extension in the media library rather than in the fs layer
parent
6b8cc251
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
2219995c
...
...
@@ -35,6 +35,7 @@ list(APPEND HEADERS_LIST
filesystem/
${
ARCH_FOLDER
}
/File.h
factory/FileSystem.h
Utils.h
)
include_directories
(
"
${
CMAKE_SOURCE_DIR
}
/include"
)
...
...
@@ -60,6 +61,7 @@ list(APPEND SRC_LIST ${HEADERS_LIST}
factory/FileSystem.cpp
filesystem/
${
ARCH_FOLDER
}
/Directory.cpp
filesystem/
${
ARCH_FOLDER
}
/File.cpp
Utils.cpp
)
find_package
(
Sqlite3 REQUIRED
)
...
...
src/MediaLibrary.cpp
View file @
2219995c
...
...
@@ -14,6 +14,7 @@
#include "Show.h"
#include "ShowEpisode.h"
#include "SqliteTools.h"
#include "Utils.h"
#include "VideoTrack.h"
#include "filesystem/IDirectory.h"
...
...
@@ -21,6 +22,23 @@
#include "factory/FileSystem.h"
const
std
::
vector
<
std
::
string
>
MediaLibrary
::
supportedExtensions
{
// Videos
"avi"
,
"3gp"
,
"amv"
,
"asf"
,
"divx"
,
"dv"
,
"flv"
,
"gxf"
,
"iso"
,
"m1v"
,
"m2v"
,
"m2t"
,
"m2ts"
,
"m4v"
,
"mkv"
,
"mov"
,
"mp2"
,
"mp4"
,
"mpeg"
,
"mpeg1"
,
"mpeg2"
,
"mpeg4"
,
"mpg"
,
"mts"
,
"mxf"
,
"nsv"
,
"nuv"
,
"ogg"
,
"ogm"
,
"ogv"
,
"ogx"
,
"ps"
,
"rec"
,
"rm"
,
"rmvb"
,
"tod"
,
"ts"
,
"vob"
,
"vro"
,
"webm"
,
"wmv"
,
// Images
"png"
,
"jpg"
,
"jpeg"
,
// Audio
"a52"
,
"aac"
,
"ac3"
,
"aiff"
,
"amr"
,
"aob"
,
"ape"
,
"dts"
,
"flac"
,
"it"
,
"m4a"
,
"m4p"
,
"mid"
,
"mka"
,
"mlp"
,
"mod"
,
"mp1"
,
"mp2"
,
"mp3"
,
"mpc"
,
"oga"
,
"ogg"
,
"oma"
,
"rmi"
,
"s3m"
,
"spx"
,
"tta"
,
"voc"
,
"vqf"
,
"w64"
,
"wav"
,
"wma"
,
"wv"
,
"xa"
,
"xm"
};
MediaLibrary
::
MediaLibrary
()
:
m_parser
(
new
Parser
)
{
...
...
@@ -104,6 +122,9 @@ FolderPtr MediaLibrary::addFolder( const std::string& path )
for
(
auto
&
f
:
dir
->
files
()
)
{
if
(
std
::
find
(
begin
(
supportedExtensions
),
end
(
supportedExtensions
),
utils
::
file
::
extension
(
f
)
)
==
end
(
supportedExtensions
)
)
continue
;
if
(
File
::
create
(
m_dbConnection
,
f
,
folder
->
id
()
)
==
nullptr
)
std
::
cerr
<<
"Failed to add file "
<<
f
<<
" to the media library"
<<
std
::
endl
;
}
...
...
src/MediaLibrary.h
View file @
2219995c
...
...
@@ -40,6 +40,9 @@ class MediaLibrary : public IMediaLibrary
virtual
void
addMetadataService
(
IMetadataService
*
service
);
virtual
void
parse
(
FilePtr
file
,
IParserCb
*
cb
);
private:
static
const
std
::
vector
<
std
::
string
>
supportedExtensions
;
private:
std
::
shared_ptr
<
sqlite3
>
m_dbConnection
;
std
::
unique_ptr
<
Parser
>
m_parser
;
...
...
src/Utils.cpp
0 → 100644
View file @
2219995c
#include "Utils.h"
namespace
utils
{
namespace
file
{
std
::
string
extension
(
const
std
::
string
&
fileName
)
{
auto
pos
=
fileName
.
find_last_of
(
'.'
);
if
(
pos
==
std
::
string
::
npos
||
pos
==
fileName
.
length
()
)
return
{};
return
fileName
.
substr
(
pos
+
1
);
}
}
}
src/Utils.h
0 → 100644
View file @
2219995c
#pragma once
#include <string>
namespace
utils
{
namespace
file
{
std
::
string
extension
(
const
std
::
string
&
fileName
);
}
}
src/filesystem/unix/Directory.cpp
View file @
2219995c
#include "Directory.h"
#include "File.h"
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <dirent.h>
...
...
@@ -13,23 +12,6 @@
namespace
fs
{
const
std
::
vector
<
std
::
string
>
Directory
::
supportedExtensions
{
// Videos
"avi"
,
"3gp"
,
"amv"
,
"asf"
,
"divx"
,
"dv"
,
"flv"
,
"gxf"
,
"iso"
,
"m1v"
,
"m2v"
,
"m2t"
,
"m2ts"
,
"m4v"
,
"mkv"
,
"mov"
,
"mp2"
,
"mp4"
,
"mpeg"
,
"mpeg1"
,
"mpeg2"
,
"mpeg4"
,
"mpg"
,
"mts"
,
"mxf"
,
"nsv"
,
"nuv"
,
"ogg"
,
"ogm"
,
"ogv"
,
"ogx"
,
"ps"
,
"rec"
,
"rm"
,
"rmvb"
,
"tod"
,
"ts"
,
"vob"
,
"vro"
,
"webm"
,
"wmv"
,
// Images
"png"
,
"jpg"
,
"jpeg"
,
// Audio
"a52"
,
"aac"
,
"ac3"
,
"aiff"
,
"amr"
,
"aob"
,
"ape"
,
"dts"
,
"flac"
,
"it"
,
"m4a"
,
"m4p"
,
"mid"
,
"mka"
,
"mlp"
,
"mod"
,
"mp1"
,
"mp2"
,
"mp3"
,
"mpc"
,
"oga"
,
"ogg"
,
"oma"
,
"rmi"
,
"s3m"
,
"spx"
,
"tta"
,
"voc"
,
"vqf"
,
"w64"
,
"wav"
,
"wma"
,
"wv"
,
"xa"
,
"xm"
};
Directory
::
Directory
(
const
std
::
string
&
path
)
:
m_path
(
toAbsolute
(
path
)
)
{
...
...
src/filesystem/unix/File.cpp
View file @
2219995c
#include "File.h"
#include "Utils.h"
namespace
fs
{
...
...
@@ -7,7 +8,7 @@ File::File( const std::string& path, const std::string& fileName )
:
m_path
(
path
)
,
m_name
(
fileName
)
,
m_fullPath
(
path
+
(
*
path
.
rbegin
()
!=
'/'
?
"/"
:
""
)
+
fileName
)
,
m_extension
(
extension
(
fileName
)
)
,
m_extension
(
utils
::
file
::
extension
(
fileName
)
)
{
}
...
...
@@ -31,12 +32,4 @@ const std::string& File::extension() const
return
m_extension
;
}
std
::
string
File
::
extension
(
const
std
::
string
&
fileName
)
{
auto
pos
=
fileName
.
find_last_of
(
'.'
);
if
(
pos
==
std
::
string
::
npos
||
pos
==
fileName
.
length
()
)
return
{};
return
fileName
.
substr
(
pos
+
1
);
}
}
src/filesystem/unix/File.h
View file @
2219995c
...
...
@@ -18,8 +18,6 @@ public:
virtual
const
std
::
string
&
fullPath
()
const
override
;
virtual
const
std
::
string
&
extension
()
const
override
;
static
std
::
string
extension
(
const
std
::
string
&
fileName
);
private:
const
std
::
string
m_path
;
const
std
::
string
m_name
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment