<commit_before>#include "musicsongtag.h"
#include "musictime.h"
#include <QStringList>
#include <QPluginLoader>
#include <QFileInfo>
///qmmp incldue
#include "decoderfactory.h"
#include "metadatamodel.h"
///

MusicSongTag::MusicSongTag()
{
    m_tag = nullptr;
}

MusicSongTag::~MusicSongTag()
{
    delete m_tag;
}

bool MusicSongTag::readFile(const QString &file)
{
    delete m_tag;
    m_tag = new TagReadAndWrite(file);
    if(!m_tag->readFile())
    {
        return readOtherTaglibNotSupport(file);
    }

    m_parameters = m_tag->getMusicTags();
    return true;
}

bool MusicSongTag::readOtherTaglibNotSupport(const QString &path)
{
    QPluginLoader loader;
    MetaDataModel *model = NULL;
    QString suffix = QFileInfo(path).suffix().toLower();

    if(suffix == "aac")
    {
#ifdef Q_OS_WIN
        loader.setFileName("plugins/Input/aac.dll");
#elif defined Q_OS_UNIX
        loader.setFileName("qmmp/Input/aac.dll");
#endif
    }
    else if(suffix == "mid")
    {
#ifdef Q_OS_WIN
        loader.setFileName("plugins/Input/wildmidi.dll");
#elif defined Q_OS_UNIX
        loader.setFileName("qmmp/Input/wildmidi.dll");
#endif
    }

    QObject *obj = loader.instance();
    if(obj)
    {
        model = qobject_cast<DecoderFactory*>(loader.instance())->createMetaDataModel(path);
    }
    if(model != NULL)
    {
        QHash<QString, QString> datas = model->audioProperties();
        MusicTime t = MusicTime::fromString(datas.value("Length"), QString("m:ss"));
        m_parameters.insert(TagReadAndWrite::TAG_LENGTH, t.toString("mm:ss"));
        m_parameters.insert(TagReadAndWrite::TAG_SAMPLERATE, datas.value("Sample rate"));
        m_parameters.insert(TagReadAndWrite::TAG_BITRATE, datas.value("Bitrate"));
        return true;
    }
    else
    {
        return false;
    }
}

QString MusicSongTag::getArtist() const<commit_msg>fix the music time incorrect when is changes[654872]<commit_after>#include "musicsongtag.h"
#include "musictime.h"
#include "musicobject.h"

#include <QStringList>
#include <QPluginLoader>
#include <QFileInfo>
///qmmp incldue
#include "decoderfactory.h"
#include "metadatamodel.h"
#include "decoder.h"
///

MusicSongTag::MusicSongTag()
{
    m_tag = nullptr;
}

MusicSongTag::~MusicSongTag()
{
    delete m_tag;
}

bool MusicSongTag::readFile(const QString &file)
{
    delete m_tag;
    m_tag = new TagReadAndWrite(file);
    if(!m_tag->readFile())
    {
        return readOtherTaglibNotSupport(file);
    }

    m_parameters = m_tag->getMusicTags();
    return true;
}

bool MusicSongTag::readOtherTaglibNotSupport(const QString &path)
{
    QPluginLoader loader;
    QString suffix = QFileInfo(path).suffix().toLower();

    if(suffix == "aac")
    {
#ifdef Q_OS_WIN
#  ifdef MUSIC_QT_5
        loader.setFileName("plugins/Input/aac.dll");
#  else
        loader.setFileName("../bin/plugins/Input/aac.dll");
#  endif
#elif defined Q_OS_UNIX
#  ifdef MUSIC_QT_5
        loader.setFileName("qmmp/Input/aac.dll");
#  else
        loader.setFileName("../lib/qmmp/Input/aac.dll");
#  endif
#endif
    }
    else if(suffix == "mid")
    {
#ifdef Q_OS_WIN
#  ifdef MUSIC_QT_5
        loader.setFileName("plugins/Input/wildmidi.dll");
#  else
        loader.setFileName("../bin/plugins/Input/wildmidi.dll");
#  endif
#elif defined Q_OS_UNIX
#  ifdef MUSIC_QT_5
        loader.setFileName("qmmp/Input/wildmidi.dll");
#  else
        loader.setFileName("../lib/qmmp/Input/wildmidi.dll");
#  endif
#endif
    }

    QObject *obj = loader.instance();
    DecoderFactory *decoderfac = NULL;
    if(obj && (decoderfac = qobject_cast<DecoderFactory*>( obj )) )
    {
        MetaDataModel *model = decoderfac->createMetaDataModel(path);
        if(model != NULL)
        {
            QHash<QString, QString> datas = model->audioProperties();
            MusicTime t = MusicTime::fromString(datas.value("Length"), QString("m:ss"));
            QString ts = QString::number(t.getTimeStamp(MusicTime::All_Msec));
            m_parameters.insert(TagReadAndWrite::TAG_LENGTH, ts);
            m_parameters.insert(TagReadAndWrite::TAG_SAMPLERATE, datas.value("Sample rate"));
            m_parameters.insert(TagReadAndWrite::TAG_BITRATE, datas.value("Bitrate"));
        }

        QList<FileInfo*> infos(decoderfac->createPlayList(path, true, 0));
        if(!infos.isEmpty())
        {
            QString t = QString::number(infos.first()->length()*1000);
            m_parameters.insert(TagReadAndWrite::TAG_LENGTH, t);
        }
    }

    return !m_parameters.isEmpty();
}

QString MusicSongTag::getArtist() const
{'fraction_non_alphanumeric': 0.14163560622670468, 'fraction_numerical': 0.00328875246656435, 'mean_word_length': 3.455078125, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1363591', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1534, 'n_words': 248}