Audio file detection by content

This commit is contained in:
Jonas Kvinge
2018-05-10 15:29:28 +02:00
parent 7b2d1d95d3
commit 5392cc4109
232 changed files with 55355 additions and 133 deletions

View File

@@ -33,14 +33,7 @@ if(WIN32)
include_directories(../3rdparty/qtwin)
endif(WIN32)
# Activate fast QString concatenation
#if (QT_VERSION_MINOR GREATER 5)
#if (QT_VERSION_MINOR GREATER 7)
add_definitions(-DQT_USE_QSTRINGBUILDER)
#else(QT_VERSION_MINOR GREATER 7)
#add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
#endif(QT_VERSION_MINOR GREATER 7)
#endif(QT_VERSION_MINOR GREATER 5)
add_definitions(-DQT_USE_QSTRINGBUILDER)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DBOOST_BIND_NO_PLACEHOLDERS)
@@ -50,11 +43,11 @@ endif()
include_directories(${CMAKE_BINARY_DIR})
include_directories(${GLIB_INCLUDE_DIRS})
include_directories(${LIBXML_INCLUDE_DIRS})
include_directories(${GOBJECT_INCLUDE_DIRS})
include_directories(${LIBXML_INCLUDE_DIRS})
include_directories(${SHA2_INCLUDE_DIRS})
include_directories(${QTSINGLEAPPLICATION_INCLUDE_DIRS})
include_directories(${QXT_INCLUDE_DIRS})
include_directories(${SHA2_INCLUDE_DIRS})
include_directories(${CHROMAPRINT_INCLUDE_DIRS})
find_package(OpenGL)
@@ -495,8 +488,8 @@ set(PHONON_ENGINE_SRC engine/phononengine.cpp)
set(PHONON_ENGINE_MOC engine/phononengine.h)
add_engine(gstreamer GSTREAMER "${GST_ENGINE_LIB}" "${GST_ENGINE_SRC}" "${GST_ENGINE_MOC}" ON)
add_engine(xine XINE LIBXINE "${XINE_ENGINE_SRC}" "${XINE_ENGINE_MOC}" ON)
add_engine(vlc VLC LIBVLC "${VLC_ENGINE_SRC}" "${VLC_ENGINE_MOC}" ON)
add_engine(xine XINE LIBXINE "${XINE_ENGINE_SRC}" "${XINE_ENGINE_MOC}" OFF)
add_engine(vlc VLC LIBVLC "${VLC_ENGINE_SRC}" "${VLC_ENGINE_MOC}" OFF)
add_engine(phonon PHONON PHONON "${PHONON_ENGINE_SRC}" "${PHONON_ENGINE_MOC}" OFF)
print_engines()

View File

@@ -35,7 +35,6 @@
#cmakedefine HAVE_QCA
#cmakedefine HAVE_SPARKLE
#cmakedefine IMOBILEDEVICE_USES_UDIDS
#cmakedefine TAGLIB_HAS_OPUS
#cmakedefine USE_INSTALL_PREFIX
#cmakedefine USE_SYSTEM_SHA2

View File

@@ -507,8 +507,8 @@ void Database::ExecSchemaCommands(QSqlDatabase &db, const QString &schema, int s
void Database::ExecSongTablesCommands(QSqlDatabase &db, const QStringList &song_tables, const QStringList &commands) {
for (const QString &command : commands) {
// There are now lots of "songs" tables that need to have the same schema:
// songs, magnatune_songs, and device_*_songs. We allow a magic value in the schema files to update all songs tables at once.
// There are now lots of "songs" tables that need to have the same schema: songs and device_*_songs.
// We allow a magic value in the schema files to update all songs tables at once.
if (command.contains(kMagicAllSongsTables)) {
for (const QString &table : song_tables) {
// Another horrible hack: device songs tables don't have matching _fts tables, so if this command tries to touch one, ignore it.

View File

@@ -20,8 +20,7 @@
#include "config.h"
#include <string>
#include "tstring.h"
#include <taglib/fileref.h>
#include <taglib/id3v1genres.h>
#include <QtGlobal>
@@ -688,31 +687,16 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) {
void Song::InitFromFilePartial(const QString &filename) {
set_url(QUrl::fromLocalFile(filename));
// We currently rely on filename suffix to know if it's a music file or not.
// TODO: I know this is not satisfying, but currently, we rely on TagLib which seems to have the behavior (filename checks).
// Someday, it would be nice to perform some magic tests everywhere.
QFileInfo info(filename);
d->basefilename_ = info.fileName();
QString suffix = info.suffix().toLower();
if (suffix == "wav" ||
suffix == "flac" ||
suffix == "ogg" ||
suffix == "oga" ||
suffix == "wv" ||
suffix == "aac" ||
suffix == "m4a" ||
suffix == "m4b" ||
suffix == "mp4" ||
suffix == "wma" ||
suffix == "mp3" ||
suffix == "mpc" ||
suffix == "tta" ||
suffix == "spx" ||
suffix == "opus") {
d->valid_ = true;
}
TagLib::FileRef fileref(filename.toUtf8().constData());
//if (TagLib::FileRef::defaultFileExtensions().contains(suffix.toUtf8().constData())) {
if (fileref.file()) d->valid_ = true;
else {
d->valid_ = false;
qLog(Error) << "File" << filename << "is not recognized by TagLib as a valid audio file.";
}
}