/** * @brief Load data using a MediaCenterInterface * @param mediaCenterInterface MediaCenterInterface to use * @return Loading was successful */ bool TvShowEpisode::loadData(MediaCenterInterface *mediaCenterInterface, bool reloadFromNfo) { if ((m_infoLoaded || hasChanged()) && m_infoFromNfoLoaded) return m_infoLoaded; bool infoLoaded; if (reloadFromNfo) infoLoaded = mediaCenterInterface->loadTvShowEpisode(this); else infoLoaded = mediaCenterInterface->loadTvShowEpisode(this, nfoContent()); if (!infoLoaded) { if (files().count() > 0) { QStringList filenameParts = files().at(0).split(QDir::separator()); QString filename = filenameParts.last(); if (filename.endsWith("VIDEO_TS.IFO", Qt::CaseInsensitive)) { if (filenameParts.count() > 1 && Helper::isDvd(files().at(0))) filename = filenameParts.at(filenameParts.count()-3); else if (filenameParts.count() > 2 && Helper::isDvd(files().at(0), true)) filename = filenameParts.at(filenameParts.count()-2); } else if (filename.endsWith("index.bdmv", Qt::CaseInsensitive)) { if (filenameParts.count() > 2) filename = filenameParts.at(filenameParts.count()-3); } setName(filename.replace(".", " ").replace("_", " ")); } } m_infoLoaded = infoLoaded; m_infoFromNfoLoaded = infoLoaded && reloadFromNfo; setChanged(false); return infoLoaded; }
/** * @brief Load data using the given MediaCenterInterface * @param mediaCenterInterface MediaCenterInterface to use * @return Loading was successful or not */ bool TvShow::loadData(MediaCenterInterface *mediaCenterInterface, bool reloadFromNfo) { if (hasChanged() || (m_infoLoaded && m_infoFromNfoLoaded && !reloadFromNfo)) return m_infoLoaded; bool infoLoaded; if (reloadFromNfo) infoLoaded = mediaCenterInterface->loadTvShow(this); else infoLoaded = mediaCenterInterface->loadTvShow(this, nfoContent()); if (!infoLoaded) { QStringList dirParts = this->dir().split(QDir::separator()); if (dirParts.count() > 0) setName(NameFormatter::instance()->formatName(dirParts.last())); } m_infoLoaded = infoLoaded; m_infoFromNfoLoaded = infoLoaded && reloadFromNfo; setChanged(false); m_hasImage.clear(); foreach (const int &imageType, TvShow::imageTypes()) m_hasImage.insert(imageType, !mediaCenterInterface->imageFileName(this, imageType).isEmpty()); m_hasImage.insert(ImageType::TvShowExtraFanart, !mediaCenterInterface->extraFanartNames(this).isEmpty()); return infoLoaded; }
/** * @brief Loads the concert infos with the given MediaCenterInterface * @param mediaCenterInterface MediaCenterInterface to use for loading * @param force Force the loading. If set to false and infos were already loeaded this function just returns * @return Loading was successful or not */ bool Concert::loadData(MediaCenterInterface *mediaCenterInterface, bool force, bool reloadFromNfo) { if ((m_infoLoaded || hasChanged()) && !force && m_infoFromNfoLoaded) return m_infoLoaded; bool infoLoaded; if (reloadFromNfo) infoLoaded = mediaCenterInterface->loadConcert(this); else infoLoaded = mediaCenterInterface->loadConcert(this, nfoContent()); if (!infoLoaded) { NameFormatter *nameFormat = NameFormatter::instance(); if (this->files().size() > 0) { QFileInfo fi(this->files().at(0)); if (QString::compare(fi.fileName(), "VIDEO_TS.IFO", Qt::CaseInsensitive) == 0) { QStringList pathElements = QDir::toNativeSeparators(fi.path()).split(QDir::separator()); if (pathElements.size() > 0 && QString::compare(pathElements.last(), "VIDEO_TS", Qt::CaseInsensitive) == 0) pathElements.removeLast(); if (pathElements.size() > 0) setName(nameFormat->formatName(pathElements.last())); } else if (QString::compare(fi.fileName(), "index.bdmv", Qt::CaseInsensitive) == 0) { QStringList pathElements = QDir::toNativeSeparators(fi.path()).split(QDir::separator()); if (pathElements.size() > 0 && QString::compare(pathElements.last(), "BDMV", Qt::CaseInsensitive) == 0) pathElements.removeLast(); if (pathElements.size() > 0) setName(nameFormat->formatName(pathElements.last())); } else if (inSeparateFolder()) { QStringList splitted = QDir::toNativeSeparators(fi.path()).split(QDir::separator()); if (!splitted.isEmpty()) { setName(nameFormat->formatName(splitted.last())); } else { if (files().size() > 1) setName(nameFormat->formatName(nameFormat->formatParts(fi.completeBaseName()))); else setName(nameFormat->formatName(fi.completeBaseName())); } } else { if (files().size() > 1) setName(nameFormat->formatName(nameFormat->formatParts(fi.completeBaseName()))); else setName(nameFormat->formatName(fi.completeBaseName())); } } } m_infoLoaded = infoLoaded; m_infoFromNfoLoaded = infoLoaded && reloadFromNfo; setChanged(false); return infoLoaded; }