Ticket #6158: MVExport.4.12.09.diff
File MVExport.4.12.09.diff, 27.9 KB (added by , 15 years ago) |
---|
-
mythplugins/mythvideo/mythvideo/globalsettings.cpp
301 301 return gc; 302 302 } 303 303 304 HostLineEdit *TVExportDirectoryFormat() 305 { 306 HostLineEdit *gc = new HostLineEdit("mythvideo.TVExportDirFormat"); 307 gc->setLabel(QObject::tr("TV Export Directory Format")); 308 gc->setValue(DEFAULT_TVEXPORTDIRFORMAT); 309 gc->setHelpText(QObject::tr("Directory format for recording export " 310 "to MythVideo, using user job style variables. Directory " 311 "is off of base MythVideo directory. Example: " 312 "Television/%CATEGORY%/%TITLE%")); 313 return gc; 314 } 315 316 HostLineEdit *TVExportFileFormat() 317 { 318 HostLineEdit *gc = new HostLineEdit("mythvideo.TVExportFileFormat"); 319 gc->setLabel(QObject::tr("TV Export File Format")); 320 gc->setValue(DEFAULT_TVEXPORTFILEFORMAT); 321 gc->setHelpText(QObject::tr("File format for recording export " 322 "to MythVideo, using user job style variables. Example: " 323 "%TITLE% %S##E##% - %SUBTITLE% (%STARTTIMEISO%)")); 324 return gc; 325 } 326 304 327 //Player Settings 305 328 306 329 HostLineEdit *VideoDefaultPlayer() … … 723 746 page1->addChild(VideoBannerDirectory()); 724 747 page1->addChild(VideoFanartDirectory()); 725 748 page1->addChild(VideoDefaultView()); 749 page1->addChild(TVExportDirectoryFormat()); 750 page1->addChild(TVExportFileFormat()); 726 751 727 752 VConfigPage page2(pages, false); 728 753 page2->addChild(VideoListUnknownFiletypes()); -
mythplugins/mythvideo/mythvideo/globals.cpp
28 28 const QString JUMP_VIDEO_TREE = "Video Listings"; 29 29 const QString JUMP_VIDEO_GALLERY = "Video Gallery"; 30 30 const QString JUMP_VIDEO_DEFAULT = "MythVideo"; 31 const QString DEFAULT_TVEXPORTDIRFORMAT = "Television/%TITLE%"; 32 const QString DEFAULT_TVEXPORTFILEFORMAT = "%TITLE% %##X##% - %SUBTITLE%"; 31 33 32 34 #ifdef Q_WS_MACX 33 35 const QString DEFAULT_VIDEOSTARTUP_DIR = QDir::homePath() + "/Movies"; -
mythplugins/mythvideo/mythvideo/globals.h
28 28 extern const QString JUMP_VIDEO_DEFAULT; 29 29 30 30 extern const QString DEFAULT_VIDEOSTARTUP_DIR; 31 extern const QString DEFAULT_TVEXPORTDIRFORMAT; 32 extern const QString DEFAULT_TVEXPORTFILEFORMAT; 31 33 32 34 #endif // GLOBALS_H_ -
mythtv/programs/mythfrontend/playbackbox.cpp
20 20 #include "mythdirs.h" 21 21 #include "mythcontext.h" 22 22 #include "mythdbcon.h" 23 #include "mythdb.h" 23 24 #include "mythverbose.h" 24 25 #include "programinfo.h" 25 26 #include "scheduledrecording.h" … … 35 36 #include "mythuibutton.h" 36 37 #include "mythuibuttonlist.h" 37 38 #include "mythuistatetype.h" 39 #include "mythuispinbox.h" 38 40 #include "mythdialogbox.h" 39 41 #include "mythuitextedit.h" 40 42 #include "mythuiimage.h" 41 43 #include "mythuicheckbox.h" 42 44 #include "mythuiprogressbar.h" 45 #include "mythprogressdialog.h" 43 46 44 47 #define LOC QString("PlaybackBox: ") 45 48 #define LOC_ERR QString("PlaybackBox Error: ") … … 51 54 52 55 #define USE_PREV_GEN_THREAD 53 56 57 QString customExportFile; 58 QString customExportDir; 59 unsigned int seasonValue = 0; 60 unsigned int episodeValue = 0; 61 unsigned int customExportSeason = 0; 62 unsigned int customExportEpisode = 0; 63 54 64 const uint PreviewGenState::maxAttempts = 5; 55 65 const uint PreviewGenState::minBlockSeconds = 60; 56 66 … … 1812 1822 RemoteStopRecording(rec); 1813 1823 } 1814 1824 1825 void PlaybackBox::mvexport(ProgramInfo *rec) 1826 { 1827 1828 // User Rating Adjustment 1829 QString exportRating = QString::number((int)((rec->stars * 10.0) + 0.5)); 1830 1831 // Stuff necessary to perform the copy command 1832 1833 QString copyFrom = rec->GetPlaybackURL(false, true); 1834 QString baseMVDir = gContext->GetSetting("VideoStartupDir"); 1835 QString MVFileFormat; 1836 QString MVDirFormat; 1837 QString copyToDir; 1838 QString copyToFile; 1839 QString extension; 1840 1841 // Check the original extension 1842 1843 QRegExp rx(".*\\.(\\w+)$"); 1844 int pos = rx.indexIn(copyFrom); 1845 if (pos > -1) 1846 { 1847 extension = rx.cap(1); 1848 } 1849 else 1850 { 1851 extension = ""; 1852 } 1853 1854 // If a custom export string is used, use it. 1855 // Also replace %VARIABLES% with actual values. 1856 1857 if (customExportFile.isEmpty() && customExportDir.isEmpty() 1858 && customExportSeason == 0 && customExportEpisode == 0) 1859 { 1860 // Season-Episode must come first for replace to work right. 1861 QString recType = rec->catType; 1862 if (recType == "movie") 1863 { 1864 seasonValue = 0; 1865 episodeValue = 0; 1866 } 1867 else 1868 { 1869 seasonValue = getLastSeason(rec->title); 1870 episodeValue = (getLastEpisode(rec->title, seasonValue) + 1); 1871 } 1872 1873 QString defaultDir = gContext->GetSetting("mythvideo.TVExportDirFormat", 1874 "Television/%TITLE%/"); 1875 QString defaultFile = gContext->GetSetting("mythvideo.TVExportFileFormat", 1876 "%TITLE% %##X##% - %SUBTITLE%"); 1877 MVDirFormat = replaceExportVariables(rec, defaultDir); 1878 MVFileFormat = replaceExportVariables(rec, defaultFile); 1879 } 1880 else 1881 { 1882 seasonValue = customExportSeason; 1883 episodeValue = customExportEpisode; 1884 MVDirFormat = replaceExportVariables(rec, customExportDir); 1885 MVFileFormat = replaceExportVariables(rec, customExportFile); 1886 } 1887 1888 copyToDir = QString("%1/%2").arg(baseMVDir).arg(MVDirFormat); 1889 copyToFile = QString("%1/%2.%3").arg(copyToDir) 1890 .arg(MVFileFormat).arg(extension); 1891 1892 // replace double slash with single 1893 1894 copyToFile.replace("//", "/"); 1895 1896 // File and Directory Definitions 1897 1898 QFile fromFile(copyFrom); 1899 QDir toDir(copyToDir); 1900 QFile toFile(copyToFile); 1901 1902 if (!toDir.exists()) 1903 { 1904 // Attempt to create path to export point. 1905 toDir.mkpath(copyToDir); 1906 toDir.mkdir(copyToDir); 1907 if (!toDir.exists()) 1908 { 1909 VERBOSE(VB_IMPORTANT, QString("Unable to create directory %1! " 1910 "Please ensure the preceding path " 1911 "exists and is writeable.").arg(copyToDir)); 1912 return; 1913 } 1914 } 1915 1916 // Perform the actual copy. 1917 1918 long long int bytesCopied = copy(toFile,fromFile); 1919 1920 if (bytesCopied != -1) 1921 { 1922 // Add File into videometadata 1923 1924 MSqlQuery query(MSqlQuery::InitCon()); 1925 1926 query.prepare("INSERT INTO videometadata (title,subtitle,director," 1927 "plot,rating,year,userrating,length,season," 1928 "episode,filename,showlevel,coverfile,inetref," 1929 "browse, trailer, screenshot, banner, fanart) VALUES " 1930 "(:TITLE, :SUBTITLE, :DIRECTOR, :PLOT, :RATING, :YEAR, " 1931 ":USERRATING, :LENGTH, :SEASON, :EPISODE, :FILENAME, " 1932 ":SHOWLEVEL, :COVERFILE, :INETREF, :BROWSE, :TRAILER, " 1933 ":SCREENSHOT, :BANNER, :FANART)"); 1934 1935 query.bindValue(":TITLE", rec->title); 1936 query.bindValue(":SUBTITLE", rec->subtitle); 1937 query.bindValue(":DIRECTOR", "Unknown"); 1938 query.bindValue(":PLOT", rec->description); 1939 query.bindValue(":RATING", "NR"); 1940 query.bindValue(":YEAR", rec->originalAirDate.toString("yyyy")); 1941 query.bindValue(":USERRATING", exportRating); 1942 query.bindValue(":LENGTH", (rec->startts.secsTo(rec->endts) / 60)); 1943 query.bindValue(":SEASON", seasonValue); 1944 query.bindValue(":EPISODE", episodeValue); 1945 query.bindValue(":FILENAME", copyToFile); 1946 query.bindValue(":SHOWLEVEL", 1); 1947 query.bindValue(":COVERFILE", "No Cover"); 1948 query.bindValue(":INETREF", QString::number(getLastInetref(rec->title))); 1949 query.bindValue(":BROWSE", 1); 1950 query.bindValue(":TRAILER", ""); 1951 query.bindValue(":SCREENSHOT", ""); 1952 query.bindValue(":BANNER", ""); 1953 query.bindValue(":FANART", ""); 1954 1955 if (!query.exec() || !query.isActive()) 1956 { 1957 MythDB::DBError("video metadata update", query); 1958 return; 1959 } 1960 1961 // Move recordedmarkup for file into videometadata 1962 1963 MSqlQuery markup(MSqlQuery::InitCon()); 1964 1965 markup.prepare("INSERT INTO filemarkup (filename,mark,offset,type) " 1966 "SELECT :FILENAME, mark, data, type from " 1967 "recordedmarkup where chanid=:CHANID and starttime=:STARTTIME"); 1968 1969 markup.bindValue(":FILENAME", copyToFile); 1970 markup.bindValue(":CHANID", rec->chanid); 1971 markup.bindValue(":STARTTIME", rec->recstartts); 1972 1973 if (!markup.exec() || !markup.isActive()) 1974 { 1975 MythDB::DBError("video metadata update", markup); 1976 return; 1977 } 1978 1979 // Copy and set preview image as screenshot 1980 // If Banners, cover files, or fanart exist with 1981 // seriesID as the name, use them automatically. 1982 1983 QString screenshotFile = getPreviewImage(rec); 1984 QString MVScreenshotDir = gContext->GetSetting("mythvideo.screenshotDir"); 1985 QString MVScreenshotFile = QString("%1/%2.png").arg(MVScreenshotDir).arg(MVFileFormat); 1986 1987 QString MVBannerDir = gContext->GetSetting("mythvideo.bannerDir"); 1988 QString bannerFile = testImageFiles(MVBannerDir, rec->seriesid, rec->title); 1989 if (!bannerFile.isNull()) 1990 VERBOSE(VB_IMPORTANT, QString("Found Banner File Match: %1").arg(bannerFile)); 1991 1992 QString MVFanartDir = gContext->GetSetting("mythvideo.fanartDir"); 1993 QString fanartFile = testImageFiles(MVFanartDir, rec->seriesid, rec->title); 1994 if (!fanartFile.isNull()) 1995 VERBOSE(VB_IMPORTANT, QString("Found Fanart File Match: %1").arg(fanartFile)); 1996 1997 QString MVCoverDir = gContext->GetSetting("VideoArtworkDir"); 1998 QString coverFile = testImageFiles(MVCoverDir, rec->seriesid, rec->title); 1999 if (!coverFile.isNull()) 2000 VERBOSE(VB_IMPORTANT, QString("Found Cover File Match: %1").arg(coverFile)); 2001 2002 VERBOSE(VB_IMPORTANT, QString("Copying %1 to %2").arg(screenshotFile).arg(MVScreenshotFile)); 2003 2004 QFile fromScreenshot(screenshotFile); 2005 QFile toScreenshot(MVScreenshotFile); 2006 long long int screenshotBytesCopied; 2007 2008 if (!screenshotFile.isNull()) 2009 screenshotBytesCopied = copy(toScreenshot,fromScreenshot); 2010 2011 if (!bannerFile.isNull() || !fanartFile.isNull() 2012 || !coverFile.isNull() || !screenshotFile.isNull()) 2013 { 2014 MSqlQuery images(MSqlQuery::InitCon()); 2015 2016 images.prepare("UPDATE videometadata set screenshot=:SCREENSHOTFILE, " 2017 "banner=:BANNERFILE, fanart=:FANARTFILE, coverfile=:COVERFILE " 2018 "where filename=:FILENAME"); 2019 2020 images.bindValue(":SCREENSHOTFILE", MVScreenshotFile); 2021 images.bindValue(":BANNERFILE", bannerFile); 2022 images.bindValue(":FANARTFILE", fanartFile); 2023 images.bindValue(":COVERFILE", coverFile); 2024 images.bindValue(":FILENAME", copyToFile); 2025 2026 if (!images.exec() || !images.isActive()) 2027 { 2028 MythDB::DBError("video metadata update", images); 2029 return; 2030 } 2031 } 2032 else 2033 { 2034 VERBOSE(VB_IMPORTANT, QString("Copy succeeded, but no images " 2035 "were copied or found.")); 2036 return; 2037 } 2038 VERBOSE(VB_IMPORTANT, QString("Copy succeeded, %1 bytes copied.").arg(bytesCopied)); 2039 } 2040 else 2041 { 2042 VERBOSE(VB_IMPORTANT, QString("Copy unsuccessful, check all permissions.")); 2043 } 2044 2045 customExportDir.clear(); 2046 customExportFile.clear(); 2047 customExportSeason = 0; 2048 customExportEpisode = 0; 2049 seasonValue = 0; 2050 episodeValue = 0; 2051 2052 } 2053 2054 unsigned int PlaybackBox::getLastSeason(QString title) 2055 { 2056 unsigned int retSeason; 2057 2058 if (!title.isEmpty()) 2059 { 2060 MSqlQuery season(MSqlQuery::InitCon()); 2061 2062 season.prepare("SELECT season from videometadata where " 2063 "title = :TITLE ORDER BY season DESC LIMIT 1"); 2064 2065 season.bindValue(":TITLE", title); 2066 2067 if (season.exec() && season.next()) 2068 { 2069 retSeason = season.value(0).toInt(); 2070 } 2071 else 2072 retSeason = 1; 2073 } 2074 2075 return retSeason; 2076 } 2077 2078 unsigned int PlaybackBox::getLastEpisode(QString title, unsigned int season) 2079 { 2080 unsigned int retEpisode; 2081 2082 if (!title.isEmpty()) 2083 { 2084 MSqlQuery episode(MSqlQuery::InitCon()); 2085 2086 episode.prepare("SELECT episode from videometadata where " 2087 "title = :TITLE AND season = :SEASON ORDER BY " 2088 "episode DESC LIMIT 1"); 2089 2090 episode.bindValue(":TITLE", title); 2091 episode.bindValue(":SEASON", season); 2092 2093 if (episode.exec() && episode.next()) 2094 { 2095 retEpisode = episode.value(0).toInt(); 2096 } 2097 else 2098 retEpisode = 0; 2099 } 2100 2101 return retEpisode; 2102 } 2103 2104 long int PlaybackBox::getLastInetref(QString title) 2105 { 2106 long int retInetref; 2107 2108 if (!title.isEmpty()) 2109 { 2110 MSqlQuery inetref(MSqlQuery::InitCon()); 2111 2112 inetref.prepare("SELECT inetref from videometadata where " 2113 "title = :TITLE ORDER BY inetref DESC LIMIT 1"); 2114 2115 inetref.bindValue(":TITLE", title); 2116 2117 if (inetref.exec() && inetref.next()) 2118 { 2119 retInetref = inetref.value(0).toInt(); 2120 } 2121 else 2122 retInetref = 0; 2123 } 2124 2125 return retInetref; 2126 } 2127 2128 QString PlaybackBox::replaceExportVariables(ProgramInfo *rec, QString &repString) 2129 { 2130 if (!repString.isEmpty()) 2131 { 2132 QString seasonOneDigit, seasonTwoDigit, episode; 2133 episode = QString::number(episodeValue); 2134 2135 if (episode.length() == 1) 2136 episode.prepend("0"); 2137 2138 seasonOneDigit = seasonTwoDigit = QString::number(seasonValue); 2139 if (seasonTwoDigit.length() == 1) 2140 seasonTwoDigit.prepend("0"); 2141 2142 repString.replace(QRegExp("%FILE%"), rec->GetRecordBasename(true)); 2143 repString.replace(QRegExp("%TITLE%"), rec->title); 2144 repString.replace(QRegExp("%SUBTITLE%"), rec->subtitle); 2145 repString.replace(QRegExp("%DESCRIPTION%"), rec->description); 2146 repString.replace(QRegExp("%INETREF%"), 2147 QString::number(getLastInetref(rec->title))); 2148 repString.replace(QRegExp("%HOSTNAME%"), rec->hostname); 2149 repString.replace(QRegExp("%CATEGORY%"), rec->category); 2150 repString.replace(QRegExp("%RECGROUP%"), rec->recgroup); 2151 repString.replace(QRegExp("%PLAYGROUP%"), rec->playgroup); 2152 repString.replace(QRegExp("%ORIGAIRYEAR%"), 2153 rec->originalAirDate.toString("yyyy")); 2154 repString.replace(QRegExp("%ORIGAIRDATE%"), 2155 rec->originalAirDate.toString("yyyyMMdd")); 2156 repString.replace(QRegExp("%CALLSIGN%"), rec->chansign); 2157 repString.replace(QRegExp("%CHANNAME%"), rec->channame); 2158 repString.replace(QRegExp("%CHANID%"), rec->chanid); 2159 repString.replace(QRegExp("%STARTTIME%"), 2160 rec->recstartts.toString("yyyyMMddhhmmss")); 2161 repString.replace(QRegExp("%ENDTIME%"), 2162 rec->recendts.toString("yyyyMMddhhmmss")); 2163 repString.replace(QRegExp("%STARTTIMEISO%"), 2164 rec->recstartts.toString(Qt::ISODate)); 2165 repString.replace(QRegExp("%ENDTIMEISO%"), 2166 rec->recendts.toString(Qt::ISODate)); 2167 repString.replace(QRegExp("%PROGSTART%"), 2168 rec->startts.toString("yyyyMMddhhmmss")); 2169 repString.replace(QRegExp("%PROGEND%"), 2170 rec->endts.toString("yyyyMMddhhmmss")); 2171 repString.replace(QRegExp("%PROGSTARTISO%"), 2172 rec->startts.toString(Qt::ISODate)); 2173 repString.replace(QRegExp("%PROGENDISO%"), 2174 rec->endts.toString(Qt::ISODate)); 2175 if (seasonValue == 0 && episodeValue == 0) 2176 { 2177 // We don't want these to show up with movies. 2178 repString.replace(QRegExp("%SEASON%"), ""); 2179 repString.replace(QRegExp("%EPISODE%"), ""); 2180 repString.replace(QRegExp("%S##E##%"), ""); 2181 repString.replace(QRegExp("%##X##%"), ""); 2182 // This replace is just to remove extra junk 2183 // from the filename if exporting a movie 2184 // with the default export. 2185 repString.replace(QRegExp(" - "), ""); 2186 } 2187 else 2188 { 2189 repString.replace(QRegExp("%SEASON%"), 2190 QString::number(seasonValue)); 2191 repString.replace(QRegExp("%EPISODE%"), 2192 QString::number(episodeValue)); 2193 repString.replace(QRegExp("%S##E##%"), 2194 QString("s%1e%2").arg(seasonTwoDigit).arg(episode)); 2195 repString.replace(QRegExp("%##X##%"), 2196 QString("%1x%2").arg(seasonOneDigit).arg(episode)); 2197 } 2198 } 2199 return repString; 2200 } 2201 1815 2202 bool PlaybackBox::doRemove(ProgramInfo *rec, bool forgetHistory, 1816 2203 bool forceMetadataDelete) 1817 2204 { … … 1926 2313 foundFile = *it; 1927 2314 break; 1928 2315 } 1929 } 2316 } 1930 2317 reg = regs[++regIndex]; 1931 2318 } 1932 2319 1933 return QString("%1/%2").arg(testDirectory).arg(foundFile);1934 } 2320 if (!foundFile.isEmpty()); 2321 return QString("%1/%2").arg(testDirectory).arg(foundFile); 1935 2322 2323 return NULL; 2324 } 2325 1936 2326 void PlaybackBox::showActions(ProgramInfo *pginfo) 1937 2327 { 1938 2328 if (!pginfo) … … 1952 2342 showActionPopup(pginfo); 1953 2343 } 1954 2344 2345 void PlaybackBox::showExportPopup(ProgramInfo *program) 2346 { 2347 if (m_popupMenu) 2348 return; 2349 2350 QString label = tr("Are you sure you want to export:"); 2351 2352 m_expItem = CurrentItem(); 2353 popupString(m_expItem, label); 2354 2355 m_popupMenu = new MythDialogBox(label, m_popupStack, "pbbmainmenupopup"); 2356 2357 connect(m_popupMenu, SIGNAL(Exiting()), SLOT(popupClosed())); 2358 2359 if (m_popupMenu->Create()) 2360 m_popupStack->AddScreen(m_popupMenu); 2361 else 2362 { 2363 delete m_popupMenu; 2364 m_popupMenu = NULL; 2365 } 2366 2367 m_popupMenu->SetReturnEvent(this, "slotmenu"); 2368 2369 m_freeSpaceNeedsUpdate = true; 2370 QString tmpmessage; 2371 const char *tmpslot = NULL; 2372 2373 if (program->IsSameProgram(*program)) 2374 { 2375 tmpmessage = tr("Yes, Export to MythVideo"); 2376 tmpslot = SLOT(doMVExport()); 2377 m_popupMenu->AddButton(tmpmessage, tmpslot); 2378 2379 tmpmessage = tr("Export (Start New Season)"); 2380 tmpslot = SLOT(doNewSeasonExport()); 2381 m_popupMenu->AddButton(tmpmessage, tmpslot); 2382 2383 tmpmessage = tr("Export with custom name/location"); 2384 tmpslot = SLOT(showCustomExportEditor()); 2385 m_popupMenu->AddButton(tmpmessage, tmpslot); 2386 2387 tmpmessage = tr("No, I don't want to Export"); 2388 tmpslot = SLOT(noExport()); 2389 m_popupMenu->AddButton(tmpmessage, tmpslot); 2390 } 2391 } 2392 2393 1955 2394 void PlaybackBox::doPIPPlay(void) 1956 2395 { 1957 2396 doPIPPlay(kPIPonTV); … … 2387 2826 else 2388 2827 m_popupMenu->AddButton(tr("Preserve this episode"), 2389 2828 SLOT(togglePreserveEpisode())); 2829 2830 QString MVlocation = FindPluginName("mythvideo"); 2831 if (QFile(MVlocation).exists()) 2832 m_popupMenu->AddButton(tr("Export to MythVideo"), SLOT(askMVExport())); 2390 2833 } 2391 2834 } 2392 2835 … … 2694 3137 stop(pginfo); 2695 3138 } 2696 3139 3140 void PlaybackBox::doMVExport() 3141 { 3142 ProgramInfo *pginfo = CurrentItem(); 3143 mvexport(pginfo); 3144 } 3145 2697 3146 void PlaybackBox::showProgramDetails() 2698 3147 { 2699 3148 ProgramInfo *pginfo = CurrentItem(); … … 2832 3281 } 2833 3282 } 2834 3283 3284 void PlaybackBox::askMVExport(ProgramInfo *pginfo) 3285 { 3286 if (!pginfo) 3287 pginfo = CurrentItem(); 3288 showExportPopup(pginfo); 3289 } 3290 2835 3291 void PlaybackBox::askDelete() 2836 3292 { 2837 3293 if (m_delItem) … … 4084 4540 m_recordingList->RemoveItem(item); 4085 4541 } 4086 4542 4543 void PlaybackBox::showCustomExportEditor() 4544 { 4545 4546 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 4547 4548 CustomExportEdit *editExport = new CustomExportEdit(mainStack); 4549 4550 if (editExport->Create()) 4551 { 4552 connect(editExport, SIGNAL(result(const QString &, const QString &, 4553 unsigned int, unsigned int)), 4554 SLOT(startCustomExport(const QString &, const QString &, 4555 unsigned int, unsigned int))); 4556 mainStack->AddScreen(editExport); 4557 } 4558 else 4559 delete editExport; 4560 } 4561 4562 void PlaybackBox::doNewSeasonExport() 4563 { 4564 MythUIButtonListItem *item = m_recordingList->GetItemCurrent(); 4565 4566 if (!item) 4567 return; 4568 4569 ProgramInfo *pginfo = CurrentItem(); 4570 4571 if (!pginfo) 4572 return; 4573 4574 customExportFile = gContext->GetSetting("mythvideo.TVExportFileFormat", 4575 "%TITLE% %##X##% - %SUBTITLE%"); 4576 customExportDir = gContext->GetSetting("mythvideo.TVExportDirFormat", 4577 "Television/%TITLE%/"); 4578 customExportSeason = (getLastSeason(pginfo->title) + 1); 4579 customExportEpisode = 1; 4580 4581 mvexport(pginfo); 4582 } 4583 4584 void PlaybackBox::startCustomExport(const QString &newFile, const QString &newDir, 4585 unsigned int newSeason, unsigned int newEpisode) 4586 { 4587 MythUIButtonListItem *item = m_recordingList->GetItemCurrent(); 4588 4589 if (!item) 4590 return; 4591 4592 ProgramInfo *pginfo = CurrentItem(); 4593 4594 if (!pginfo) 4595 return; 4596 4597 customExportFile = newFile; 4598 customExportDir = newDir; 4599 customExportSeason = newSeason; 4600 customExportEpisode = newEpisode; 4601 4602 mvexport(pginfo); 4603 } 4604 4087 4605 void PlaybackBox::setRecGroup(QString newRecGroup) 4088 4606 { 4089 4607 ProgramInfo *tmpItem = CurrentItem(); … … 4469 4987 Close(); 4470 4988 } 4471 4989 4990 //////////////////////////////////////////////////////// 4991 4992 CustomExportEdit::CustomExportEdit(MythScreenStack *lparent) 4993 : MythScreenType(lparent, "customexportedit") 4994 { 4995 m_dirEdit = m_fileEdit = NULL; 4996 } 4997 4998 bool CustomExportEdit::Create() 4999 { 5000 if (!LoadWindowFromXML("recordings-ui.xml", "customexport", this)) 5001 return false; 5002 5003 m_dirEdit = dynamic_cast<MythUITextEdit*>(GetChild("dir")); 5004 m_fileEdit = dynamic_cast<MythUITextEdit*>(GetChild("file")); 5005 m_seasonSpin = dynamic_cast<MythUISpinBox *>(GetChild("season")); 5006 m_episodeSpin = dynamic_cast<MythUISpinBox *>(GetChild("episode")); 5007 5008 MythUIButton *okButton = dynamic_cast<MythUIButton*>(GetChild("ok")); 5009 5010 if (!m_dirEdit || !m_fileEdit || !m_seasonSpin || 5011 !m_episodeSpin || !okButton) 5012 { 5013 VERBOSE(VB_IMPORTANT, "Window 'customexport' is missing required " 5014 "elements."); 5015 return false; 5016 } 5017 5018 m_dirEdit->SetText(gContext->GetSetting("mythvideo.TVExportDirFormat"), 5019 "Television/%TITLE%/"); 5020 m_fileEdit->SetText(gContext->GetSetting("mythvideo.TVExportFileFormat"), 5021 "%TITLE% %##X##% - %SUBTITLE%"); 5022 m_seasonSpin->SetRange(0,100,1); 5023 m_seasonSpin->SetValue(1); 5024 m_episodeSpin->SetRange(0,999,1); 5025 m_episodeSpin->SetValue(1); 5026 5027 connect(okButton, SIGNAL(Clicked()), SLOT(ReturnExport())); 5028 5029 if (!BuildFocusList()) 5030 VERBOSE(VB_IMPORTANT, "Failed to build a focuslist."); 5031 5032 return true; 5033 } 5034 5035 void CustomExportEdit::ReturnExport() 5036 { 5037 QString newExportDir = m_dirEdit->GetText(); 5038 QString newExportFile = m_fileEdit->GetText(); 5039 unsigned int newSeason = m_seasonSpin->GetIntValue(); 5040 unsigned int newEpisode = m_episodeSpin->GetIntValue(); 5041 5042 emit result(newExportFile, newExportDir, newSeason, newEpisode); 5043 Close(); 5044 } 5045 4472 5046 ////////////////////////////////////////// 4473 5047 4474 5048 HelpPopup::HelpPopup(MythScreenStack *lparent) -
mythtv/programs/mythfrontend/playbackbox.h
142 142 void showRecGroupChanger(); 143 143 void showPlayGroupChanger(); 144 144 void showMetadataEditor(); 145 void showCustomExportEditor(); 145 146 void showGroupFilter(); 146 147 void showRecGroupPasswordChanger(); 147 148 MythDialogBox *createPopupMenu(const QString &title); … … 178 179 179 180 void askStop(); 180 181 void doStop(); 182 void askMVExport(ProgramInfo *pginfo = NULL); 183 void doMVExport(); 181 184 182 185 void doEditScheduled(); 183 186 void doAllowRerecord(); … … 208 211 void setPlayGroup(QString newPlayGroup); 209 212 210 213 void saveRecMetadata(const QString &newTitle, const QString &newSubtitle); 214 void startCustomExport(const QString &newFile, const QString &newDir, 215 unsigned int newSeason, unsigned int newEpisode); 216 void doNewSeasonExport(); 211 217 212 218 void SetRecGroupPassword(const QString &newPasswd); 213 219 … … 254 260 255 261 void checkPassword(const QString &password); 256 262 263 257 264 protected: 258 265 bool SetPreviewGenerator(const QString &fn, PreviewGenerator *g); 259 266 void IncPreviewGeneratorPriority(const QString &fn); … … 271 278 272 279 bool play(ProgramInfo *rec, bool inPlaylist = false); 273 280 void stop(ProgramInfo *); 281 void mvexport(ProgramInfo *); 282 unsigned int getLastSeason(QString title); 283 unsigned int getLastEpisode(QString title, unsigned int season); 284 long int getLastInetref(QString title); 285 QString replaceExportVariables(ProgramInfo *rec, QString &repString); 274 286 void remove(ProgramInfo *); 275 287 void showActions(ProgramInfo *); 276 288 ProgramInfo *CurrentItem(void); … … 290 302 291 303 bool doRemove(ProgramInfo *, bool forgetHistory, bool forceMetadataDelete); 292 304 void showDeletePopup(deletePopupType); 305 void showExportPopup(ProgramInfo *); 293 306 void showActionPopup(ProgramInfo *program); 294 307 void showFileNotFoundActionPopup(ProgramInfo *program); 295 308 void popupString(ProgramInfo *program, QString &message); … … 390 403 // Other state 391 404 /// Program currently selected for deletion 392 405 ProgramInfo *m_delItem; 406 /// Program currently selected for export 407 ProgramInfo *m_expItem; 393 408 /// Program currently selected during an update 394 409 ProgramInfo *m_currentItem; 395 410 /// Group currently selected … … 526 541 private: 527 542 MythUITextEdit *m_titleEdit; 528 543 MythUITextEdit *m_subtitleEdit; 544 MythUITextEdit *m_descriptionEdit; 529 545 530 546 ProgramInfo *m_progInfo; 531 547 }; 532 548 549 class CustomExportEdit : public MythScreenType 550 { 551 Q_OBJECT 552 553 public: 554 CustomExportEdit(MythScreenStack *lparent); 555 556 bool Create(void); 557 558 signals: 559 void result(const QString &, const QString &, unsigned int, unsigned int); 560 561 protected slots: 562 void ReturnExport(void); 563 564 private: 565 MythUITextEdit *m_dirEdit; 566 MythUITextEdit *m_fileEdit; 567 MythUISpinBox *m_seasonSpin; 568 MythUISpinBox *m_episodeSpin; 569 570 }; 571 533 572 class HelpPopup : public MythScreenType 534 573 { 535 574 Q_OBJECT