void ActiveMapsLayout::UpdateAll() { vector<Item> toDownload; toDownload.reserve(m_items.size()); for (int i = m_split.first; i < m_split.second; ++i) { Item const & item = m_items[i]; if (item.m_status != TStatus::EInQueue && item.m_status != TStatus::EDownloading) toDownload.push_back(item); } for (Item const & item : toDownload) DownloadMap(item.Index(), item.m_options); }
MetadataLookup* ParseMetadataItem(const QDomElement& item, MetadataLookup *lookup, bool passseas) { if (!lookup) return new MetadataLookup(); uint season = 0, episode = 0, chanid = 0, programflags = 0, audioproperties = 0, videoproperties = 0, subtitletype = 0, tracknum = 0, popularity = 0, budget = 0, revenue = 0, year = 0, runtime = 0, runtimesecs = 0, ratingcount = 0; QString title, network, status, subtitle, tagline, description, certification, channum, chansign, channame, chanplaybackfilters, recgroup, playgroup, seriesid, programid, storagegroup, album, system, inetref, collectionref, tmsref, imdb, homepage, trailerURL, language; QStringList categories, countries, studios; float userrating = 0; QDate releasedate; QDateTime lastupdated, startts, endts, recstartts, recendts; PeopleMap people; ArtworkMap artwork; // Get the easy parses language = item.firstChildElement("language").text(); title = Parse::UnescapeHTML(item.firstChildElement("title").text()); network = Parse::UnescapeHTML(item.firstChildElement("network").text()); status = Parse::UnescapeHTML(item.firstChildElement("status").text()); subtitle = Parse::UnescapeHTML(item.firstChildElement("subtitle").text()); tagline = Parse::UnescapeHTML(item.firstChildElement("tagline").text()); description = Parse::UnescapeHTML(item.firstChildElement("description").text()); album = Parse::UnescapeHTML(item.firstChildElement("albumname").text()); inetref = item.firstChildElement("inetref").text(); collectionref = item.firstChildElement("collectionref").text(); tmsref = item.firstChildElement("tmsref").text(); imdb = item.firstChildElement("imdb").text(); homepage = item.firstChildElement("homepage").text(); trailerURL = item.firstChildElement("trailer").text(); // ProgramInfo specific parsing chanid = item.firstChildElement("chanid").text().toUInt(); channum = item.firstChildElement("channum").text(); chansign = item.firstChildElement("chansign").text(); channame = item.firstChildElement("channame").text(); chanplaybackfilters = item.firstChildElement("chanplaybackfilters").text(); recgroup = item.firstChildElement("recgroup").text(); playgroup = item.firstChildElement("playgroup").text(); seriesid = item.firstChildElement("seriesid").text(); programid = item.firstChildElement("programid").text(); storagegroup = item.firstChildElement("storagegroup").text(); startts = RFC822TimeToQDateTime(item. firstChildElement("startts").text()); endts = RFC822TimeToQDateTime(item. firstChildElement("endts").text()); recstartts = RFC822TimeToQDateTime(item. firstChildElement("recstartts").text()); recendts = RFC822TimeToQDateTime(item. firstChildElement("recendts").text()); programflags = item.firstChildElement("programflags").text().toUInt(); audioproperties = item.firstChildElement("audioproperties").text().toUInt(); videoproperties = item.firstChildElement("videoproperties").text().toUInt(); subtitletype = item.firstChildElement("subtitletype").text().toUInt(); QString tmpDate = item.firstChildElement("releasedate").text(); if (!tmpDate.isEmpty()) releasedate = QDate::fromString(tmpDate, "yyyy-MM-dd"); lastupdated = RFC822TimeToQDateTime(item. firstChildElement("lastupdated").text()); userrating = item.firstChildElement("userrating").text().toFloat(); ratingcount = item.firstChildElement("ratingcount").text().toUInt(); tracknum = item.firstChildElement("tracknum").text().toUInt(); popularity = item.firstChildElement("popularity").text().toUInt(); budget = item.firstChildElement("budget").text().toUInt(); revenue = item.firstChildElement("revenue").text().toUInt(); year = item.firstChildElement("year").text().toUInt(); if (!year && !releasedate.isNull()) year = releasedate.toString("yyyy").toUInt(); runtime = item.firstChildElement("runtime").text().toUInt(); runtimesecs = item.firstChildElement("runtimesecs").text().toUInt(); QDomElement systems = item.firstChildElement("systems"); if (!systems.isNull()) { QDomElement firstSystem = systems.firstChildElement("system"); if (!firstSystem.isNull()) system = firstSystem.text(); } // TODO: Once TMDB supports certification per-locale, come back and match // locale of myth to certification locale. QDomElement certifications = item.firstChildElement("certifications"); QList< QPair<QString,QString> > ratinglist; if (!certifications.isNull()) { QDomElement cert = certifications.firstChildElement("certification"); if (!cert.isNull()) { while (!cert.isNull()) { if (cert.hasAttribute("locale") && cert.hasAttribute("name")) { QPair<QString,QString> newcert(cert.attribute("locale"), cert.attribute("name")); ratinglist.append(newcert); } cert = cert.nextSiblingElement("certification"); } } } // HACK: To go away when someone supports ratings by locale. if (!ratinglist.isEmpty()) certification = ratinglist.takeFirst().second; // Categories QDomElement categoriesxml = item.firstChildElement("categories"); if (!categoriesxml.isNull()) { QDomElement cat = categoriesxml.firstChildElement("category"); if (!cat.isNull()) { while (!cat.isNull()) { if (cat.hasAttribute("name")) categories.append(cat.attribute("name")); cat = cat.nextSiblingElement("category"); } } } // Countries QDomElement countriesxml = item.firstChildElement("countries"); if (!countriesxml.isNull()) { QDomElement cntry = countriesxml.firstChildElement("country"); if (!cntry.isNull()) { while (!cntry.isNull()) { if (cntry.hasAttribute("name")) countries.append(cntry.attribute("name")); cntry = cntry.nextSiblingElement("country"); } } } // Studios QDomElement studiosxml = item.firstChildElement("studios"); if (!studiosxml.isNull()) { QDomElement studio = studiosxml.firstChildElement("studio"); if (!studio.isNull()) { while (!studio.isNull()) { if (studio.hasAttribute("name")) studios.append(studio.attribute("name")); studio = studio.nextSiblingElement("studio"); } } } // People QDomElement peoplexml = item.firstChildElement("people"); if (!peoplexml.isNull()) { people = ParsePeople(peoplexml); } // Artwork QDomElement artworkxml = item.firstChildElement("images"); if (!artworkxml.isNull()) { artwork = ParseArtwork(artworkxml); } // Have to handle season and episode a little differently. // If the query object comes in with a season or episode number, // we want to pass that through. However, if we are doing a title/subtitle // lookup, we need to parse for season and episode. if (passseas) { season = lookup->GetSeason(); episode = lookup->GetEpisode(); } else { if (lookup->GetPreferDVDOrdering()) { season = item.firstChildElement("dvdseason").text().toUInt(); episode = item.firstChildElement("dvdepisode").text().toUInt(); } if ((season == 0) && (episode == 0)) { season = item.firstChildElement("season").text().toUInt(); episode = item.firstChildElement("episode").text().toUInt(); } LOG(VB_GENERAL, LOG_INFO, QString("Result Found, Season %1 Episode %2") .arg(season).arg(episode)); } return new MetadataLookup(lookup->GetType(), lookup->GetSubtype(), lookup->GetData(), lookup->GetStep(), lookup->GetAutomatic(), lookup->GetHandleImages(), lookup->GetAllowOverwrites(), lookup->GetAllowGeneric(), lookup->GetPreferDVDOrdering(), lookup->GetHost(), lookup->GetFilename(), title, network, status, categories, userrating, ratingcount, language, subtitle, tagline, description, season, episode, chanid, channum, chansign, channame, chanplaybackfilters, recgroup, playgroup, seriesid, programid, storagegroup, startts, endts, recstartts, recendts, programflags, audioproperties, videoproperties, subtitletype, certification, countries, popularity, budget, revenue, album, tracknum, system, year, releasedate, lastupdated, runtime, runtimesecs, inetref, collectionref, tmsref, imdb, people, studios, homepage, trailerURL, artwork, DownloadMap()); }
MetadataLookup* ParseMetadataMovieNFO(const QDomElement& item, MetadataLookup *lookup) { if (!lookup) return new MetadataLookup(); uint year = 0, runtime = 0, runtimesecs = 0, season = 0, episode = 0; QString title, subtitle, tagline, description, inetref, trailer, certification; float userrating = 0; QDate releasedate; QStringList categories; PeopleMap people; ArtworkMap artwork; // Get the easy parses QString titletmp; if (item.tagName() == "movie") title = Parse::UnescapeHTML(item.firstChildElement("title").text()); else if (item.tagName() == "episodedetails") subtitle = Parse::UnescapeHTML(item.firstChildElement("title").text()); userrating = item.firstChildElement("rating").text().toFloat(); year = item.firstChildElement("year").text().toUInt(); season = item.firstChildElement("season").text().toUInt(); episode = item.firstChildElement("episode").text().toUInt(); description = Parse::UnescapeHTML(item.firstChildElement("plot").text()); tagline = Parse::UnescapeHTML(item.firstChildElement("tagline").text()); inetref = item.firstChildElement("id").text(); trailer = item.firstChildElement("trailer").text(); certification = item.firstChildElement("mpaa").text(); categories.append(item.firstChildElement("genre").text()); QString tmpDate = item.firstChildElement("releasedate").text(); if (!tmpDate.isEmpty()) releasedate = QDate::fromString(tmpDate, "yyyy-MM-dd"); else if (year > 0) releasedate = QDate::fromString(QString::number(year), "yyyy"); runtime = item.firstChildElement("runtime").text() .remove(QRegExp("[A-Za-z]")) .trimmed().toUInt(); runtimesecs = runtime * 60; QDomElement actor = item.firstChildElement("actor"); if (!actor.isNull()) { while (!actor.isNull()) { PersonInfo info; info.name = actor.firstChildElement("name").text(); info.role = actor.firstChildElement("role").text(); info.thumbnail = actor.firstChildElement("thumb").text(); people.insert(kPersonActor, info); actor = actor.nextSiblingElement("actor"); } } QString director = item.firstChildElement("director").text(); if (!director.isEmpty()) { PersonInfo info; info.name = director; people.insert(kPersonDirector, info); } return new MetadataLookup(lookup->GetType(), lookup->GetSubtype(), lookup->GetData(), lookup->GetStep(), lookup->GetAutomatic(), lookup->GetHandleImages(), lookup->GetAllowOverwrites(), lookup->GetAllowGeneric(), lookup->GetPreferDVDOrdering(), lookup->GetHost(), lookup->GetFilename(), title, categories, userrating, subtitle, tagline, description, season, episode, certification, year, releasedate, runtime, runtimesecs, inetref, people, trailer, artwork, DownloadMap()); }
void ImportFile::doGetRecording(void) { MythUIButtonListItem *item = m_recordingButtonList->GetItemCurrent(); if (!item) return; ImportItem *i = item->GetData().value<ImportItem *>(); if (!i) return; uint duration = 60; //i->actualDuration; QString videoFile = getTempDirectory() + "work/video.ts"; QString mxmlFile = getTempDirectory() + "work/video.mxml"; // record the mp4 video stream QString recCommand = QString("mythffmpeg -y -i %1 -t %2 -acodec copy -vcodec copy %3") .arg(STREAMURL).arg(duration).arg(videoFile); QScopedPointer<MythSystem> cmd(MythSystem::Create(recCommand, kMSRunShell)); cmd->Wait(0); if (cmd.data()->GetExitCode() != GENERIC_EXIT_OK) { LOG(VB_GENERAL, LOG_ERR, QString("ERROR - ffmpeg exited with result: %1").arg(cmd.data()->GetExitCode())); return; } // create a mxml file with the metadata for this recording QStringList categories(i->category.split(',')); MetadataLookup *lookup = new MetadataLookup(kMetadataVideo, kProbableTelevision, QVariant(), kLookupSearch, false, false, false, false, false, "", videoFile, i->title, categories, 0.0, i->subtitle, "", i->description, i->season, i->episode, i->startTime, 0, i->chanNo, i->chanSign, i->chanName, i->certification, i->startTime.date().year(), i->startTime.date(), i->duration / 60, i->duration, "", PeopleMap(), "", ArtworkMap(), DownloadMap()); if (i->category == "Movies") lookup->SetVideoContentType(kContentMovie); else lookup->SetVideoContentType(kContentTelevision); QDomDocument mxmlDoc = CreateMetadataXML(lookup); // save the mxml to the file QFile f(mxmlFile); if (!f.open(QIODevice::WriteOnly)) { LOG(VB_GENERAL, LOG_ERR, QString("ImportFile: Failed to open mxml file for writing - %1").arg(mxmlFile)); return; } QTextStream t(&f); t << mxmlDoc.toString(4); f.close(); // workout where to save the file in the Video storage group QString dstFile = filenameFromMetadataLookup(lookup); QString saveFilename; // copy the recording to the Video storage group saveFilename = gCoreContext->GenMythURL(gCoreContext->GetMasterHostName(), 0, dstFile + ".mp4", "Videos"); bool result = RemoteFile::CopyFile(videoFile, saveFilename); if (!result) { LOG(VB_GENERAL, LOG_ERR, QString("ImportFile: Failed to copy video file to %1").arg(saveFilename)); return; } // copy the metadata xml file to the Video storage group saveFilename = gCoreContext->GenMythURL(gCoreContext->GetMasterHostName(), 0, dstFile + ".mxml", "Videos"); result = RemoteFile::CopyFile(mxmlFile, saveFilename); if (!result) { LOG(VB_GENERAL, LOG_ERR, QString("ImportFile: Failed to copy xml file to %1").arg(saveFilename)); return; } }