void NetTree::doDeleteVideo(bool remove) { if (!remove) return; ResultItem *item; if (m_type == DLG_TREE) item = qVariantValue<ResultItem *>(m_siteMap->GetCurrentNode()->GetData()); else { MythGenericTree *node = GetNodePtrFromButton(m_siteButtonList->GetItemCurrent()); if (!node) return; item = qVariantValue<ResultItem *>(node->GetData()); } if (!item) return; QString filename = GetDownloadFilename(item->GetTitle(), item->GetMediaURL()); if (filename.startsWith("myth://")) RemoteFile::DeleteFile(filename); else { QFile file(filename); file.remove(); } }
void NetTree::streamWebVideo() { ResultItem *item; if (m_type == DLG_TREE) item = qVariantValue<ResultItem *>(m_siteMap->GetCurrentNode()->GetData()); else { MythGenericTree *node = GetNodePtrFromButton(m_siteButtonList->GetItemCurrent()); if (!node) return; item = qVariantValue<ResultItem *>(node->GetData()); } if (!item) return; if (!item->GetDownloadable()) { showWebVideo(); return; } GetMythMainWindow()->HandleMedia("Internal", item->GetMediaURL(), item->GetDescription(), item->GetTitle(), item->GetSubtitle(), QString(), item->GetSeason(), item->GetEpisode(), QString(), item->GetTime().toInt(), item->GetDate().toString("yyyy")); }
void NetTree::doDownloadAndPlay() { ResultItem *item; if (m_type == DLG_TREE) item = qVariantValue<ResultItem *>(m_siteMap->GetCurrentNode()->GetData()); else { MythGenericTree *node = GetNodePtrFromButton(m_siteButtonList->GetItemCurrent()); if (!node) return; item = qVariantValue<ResultItem *>(node->GetData()); } if (!item) return; QString baseFilename = GetDownloadFilename(item->GetTitle(), item->GetMediaURL()); QString finalFilename = generate_file_url("Default", gCoreContext->GetMasterHostName(), baseFilename); LOG(VB_GENERAL, LOG_INFO, QString("Downloading %1 to %2") .arg(item->GetMediaURL()) .arg(finalFilename)); // Does the file already exist? bool exists = RemoteFile::Exists(finalFilename); if (exists) { doPlayVideo(finalFilename); return; } else DownloadVideo(item->GetMediaURL(), baseFilename); }
void NetTree::showWebVideo() { ResultItem *item; if (m_type == DLG_TREE) item = qVariantValue<ResultItem *>(m_siteMap->GetCurrentNode()->GetData()); else { MythGenericTree *node = GetNodePtrFromButton(m_siteButtonList->GetItemCurrent()); if (!node) return; item = qVariantValue<ResultItem *>(node->GetData()); } if (!item) return; if (!item->GetPlayer().isEmpty()) { QString cmd = item->GetPlayer(); QStringList args = item->GetPlayerArguments(); if (!args.size()) { args += item->GetMediaURL(); if (!args.size()) args += item->GetURL(); } else { args.replaceInStrings("%DIR%", QString(GetConfDir() + "/MythNetvision")); args.replaceInStrings("%MEDIAURL%", item->GetMediaURL()); args.replaceInStrings("%URL%", item->GetURL()); args.replaceInStrings("%TITLE%", item->GetTitle()); } QString playerCommand = cmd + " " + args.join(" "); myth_system(playerCommand); } else { QString url = item->GetURL(); LOG(VB_GENERAL, LOG_DEBUG, QString("Web URL = %1").arg(url)); if (url.isEmpty()) return; QString browser = gCoreContext->GetSetting("WebBrowserCommand", ""); QString zoom = gCoreContext->GetSetting("WebBrowserZoomLevel", "1.0"); if (browser.isEmpty()) { ShowOkPopup(tr("No browser command set! MythNetTree needs MythBrowser " "installed to display the video.")); return; } if (browser.toLower() == "internal") { GetMythMainWindow()->HandleMedia("WebBrowser", url); return; } else { QString cmd = browser; cmd.replace("%ZOOM%", zoom); cmd.replace("%URL%", url); cmd.replace('\'', "%27"); cmd.replace("&","\\&"); cmd.replace(";","\\;"); GetMythMainWindow()->AllowInput(false); myth_system(cmd, kMSDontDisableDrawing); GetMythMainWindow()->AllowInput(true); return; } } }
void NetSearch::ShowMenu(void) { QString label = tr("Search Options"); MythDialogBox *menuPopup = new MythDialogBox(label, m_popupStack, "mythnetvisionmenupopup"); if (menuPopup->Create()) { m_popupStack->AddScreen(menuPopup); menuPopup->SetReturnEvent(this, "options"); if (m_searchResultList->GetCount() > 0) { ResultItem *item = GetStreamItem(); if (item) { if (item->GetDownloadable()) menuPopup->AddButton(tr("Stream Video"), SLOT(StreamWebVideo())); menuPopup->AddButton(tr("Open Web Link"), SLOT(ShowWebVideo())); QString filename = GetDownloadFilename(item->GetTitle(), item->GetMediaURL()); bool exists = false; if (filename.startsWith("myth://")) exists = RemoteFile::Exists(filename); else exists = QFile::exists(filename); if (item->GetDownloadable() && GetFocusWidget() == m_searchResultList) { if (exists) menuPopup->AddButton(tr("Play"), SLOT(DoPlayVideo(filename))); else menuPopup->AddButton(tr("Save This Video"), SLOT(DoDownloadAndPlay())); } if (item->GetDownloadable() && GetFocusWidget() == m_searchResultList && exists) { menuPopup->AddButton(tr("Delete"), SLOT(SlotDeleteVideo())); } } if (m_pagenum > 1) menuPopup->AddButton(tr("Previous Page"), SLOT(GetLastResults())); if (m_searchResultList->GetCount() > 0 && m_pagenum < m_maxpage) menuPopup->AddButton(tr("Next Page"), SLOT(GetMoreResults())); } menuPopup->AddButton(tr("Manage Search Scripts"), SLOT(RunSearchEditor())); } else delete menuPopup; }
void NetSearch::showWebVideo() { QMutexLocker locker(&m_lock); ResultItem *item = qVariantValue<ResultItem *>(m_searchResultList->GetDataValue()); if (!item) return; if (!item->GetPlayer().isEmpty()) { QString cmd = item->GetPlayer(); QStringList args = item->GetPlayerArguments(); if (!args.size()) { args += item->GetMediaURL(); if (!args.size()) args += item->GetURL(); } else { args.replaceInStrings("%DIR%", QString(GetConfDir() + "/MythNetvision")); args.replaceInStrings("%MEDIAURL%", item->GetMediaURL()); args.replaceInStrings("%URL%", item->GetURL()); args.replaceInStrings("%TITLE%", item->GetTitle()); } QString playerCommand = cmd + " " + args.join(" "); myth_system(playerCommand); } else { QString url = item->GetURL(); VERBOSE(VB_GENERAL|VB_EXTRA, QString("Web URL = %1").arg(url)); if (url.isEmpty()) return; QString browser = gCoreContext->GetSetting("WebBrowserCommand", ""); QString zoom = gCoreContext->GetSetting("WebBrowserZoomLevel", "1.0"); if (browser.isEmpty()) { ShowOkPopup(tr("No browser command set! MythNetVision needs MythBrowser " "installed to display the video.")); return; } if (browser.toLower() == "internal") { GetMythMainWindow()->HandleMedia("WebBrowser", url); return; } else { QString cmd = browser; cmd.replace("%ZOOM%", zoom); cmd.replace("%URL%", url); cmd.replace('\'', "%27"); cmd.replace("&","\\&"); cmd.replace(";","\\;"); GetMythMainWindow()->AllowInput(false); myth_system(cmd, kMSDontDisableDrawing); GetMythMainWindow()->AllowInput(true); return; } } }