mirror of
https://github.com/KDE/kasts.git
synced 2025-02-06 12:24:18 +01:00
Retrieve duration from file as soon as it's downloaded
This will replace the less reliable duration as retrieved from the rss feed entry. BUG: 497448
This commit is contained in:
parent
02aefde5d9
commit
e77f317f91
@ -17,6 +17,7 @@
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include <attachedpictureframe.h>
|
||||
#include <fileref.h>
|
||||
#include <id3v2frame.h>
|
||||
#include <id3v2tag.h>
|
||||
#include <mpegfile.h>
|
||||
@ -237,11 +238,20 @@ void Enclosure::processDownloadedFile()
|
||||
// if not, correct the filesize in the database
|
||||
// otherwise the file will get deleted because of mismatch in signature
|
||||
if (m_sizeOnDisk != size()) {
|
||||
qCDebug(kastsEnclosure) << "Correcting enclosure file size mismatch" << m_entry->title() << "from" << size() << "to" << m_sizeOnDisk;
|
||||
qCDebug(kastsEnclosure) << "Correcting enclosure file size mismatch for" << m_entry->title() << "from" << size() << "to" << m_sizeOnDisk;
|
||||
setSize(m_sizeOnDisk);
|
||||
setStatus(Downloaded);
|
||||
}
|
||||
|
||||
// Check the duration inside the tag, it should be more accurate than the
|
||||
// value from the feed entry
|
||||
TagLib::FileRef f(path().toLatin1().data());
|
||||
int fileduration = f.audioProperties()->lengthInSeconds();
|
||||
if (fileduration > 0 && fileduration != duration()) {
|
||||
qCDebug(kastsEnclosure) << "Correcting enclosure duration mismatch for" << m_entry->title() << "from" << duration() << "to" << fileduration;
|
||||
setDuration(fileduration);
|
||||
}
|
||||
|
||||
// Unset "new" status of item
|
||||
if (m_entry->getNew()) {
|
||||
m_entry->setNew(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user