Go to the documentation of this file.
9 #include <QCoreApplication>
11 #include <QDomDocument>
30 QT_TRANSLATE_NOOP(
"SelectDestination",
"Single Layer DVD"),
31 QT_TRANSLATE_NOOP(
"SelectDestination",
"Single Layer DVD (4,482 MB)"),
34 QT_TRANSLATE_NOOP(
"SelectDestination",
"Dual Layer DVD"),
35 QT_TRANSLATE_NOOP(
"SelectDestination",
"Dual Layer DVD (8,964 MB)"),
38 QT_TRANSLATE_NOOP(
"SelectDestination",
"DVD +/- RW"),
39 QT_TRANSLATE_NOOP(
"SelectDestination",
"Rewritable DVD"),
42 QT_TRANSLATE_NOOP(
"SelectDestination",
"File"),
43 QT_TRANSLATE_NOOP(
"SelectDestination",
"Any file accessable from your filesystem."),
49 if (sizeKB>1024*1024*1024)
51 double sizeGB = sizeKB/(1024*1024*1024.0);
52 return QString(
"%1 TB").arg(sizeGB, 0,
'f', (sizeGB>10)?0:prec);
56 double sizeGB = sizeKB/(1024*1024.0);
57 return QString(
"%1 GB").arg(sizeGB, 0,
'f', (sizeGB>10)?0:prec);
61 double sizeMB = sizeKB/1024.0;
62 return QString(
"%1 MB").arg(sizeMB, 0,
'f', (sizeMB>10)?0:prec);
65 return QString(
"%1 KB").arg(sizeKB);
72 if (tempDir ==
"" && showError)
74 ShowOkPopup(QCoreApplication::translate(
"(ArchiveUtils)",
75 "Cannot find the MythArchive work directory.\n"
76 "Have you set the correct path in the settings?"));
83 if (!tempDir.endsWith(
"/"))
95 QString logDir = tempDir +
"logs";
96 QString configDir = tempDir +
"config";
97 QString workDir = tempDir +
"work";
104 if( chmod(qPrintable(tempDir), 0777) != 0 )
105 LOG(VB_GENERAL, LOG_ERR,
106 "Failed to change permissions on archive directory: " +
ENO);
109 dir.setPath(workDir);;
113 if( chmod(qPrintable(workDir), 0777) != 0 )
115 LOG(VB_GENERAL, LOG_ERR,
116 "Failed to change permissions on archive work directory: " +
121 dir.setPath(logDir);;
125 if( chmod(qPrintable(logDir), 0777) != 0 )
127 LOG(VB_GENERAL, LOG_ERR,
128 "Failed to change permissions on archive log directory: " +
132 dir.setPath(configDir);;
135 dir.mkdir(configDir);
136 if( chmod(qPrintable(configDir), 0777) != 0 )
138 LOG(VB_GENERAL, LOG_ERR,
139 "Failed to change permissions on archive config directory: " +
148 int pos =
filename.lastIndexOf(
'/');
156 QString &chanID, QString &startTime)
158 LOG(VB_JOBQUEUE, LOG_INFO,
"Extracting details from: " + inFile);
163 query.
prepare(
"SELECT chanid, starttime FROM recorded "
164 "WHERE basename = :BASENAME");
169 chanID = query.
value(0).toString();
170 startTime= query.
value(1).toString();
174 LOG(VB_JOBQUEUE, LOG_ERR,
175 QString(
"Cannot find details for %1").arg(inFile));
179 LOG(VB_JOBQUEUE, LOG_INFO,
180 QString(
"chanid: %1 starttime:%2 ").arg(chanID, startTime));
193 if (bIsMythRecording)
195 uint chanid = chanID.toUInt();
213 LOG(VB_JOBQUEUE, LOG_NOTICE,
"File is not a MythTV recording.");
216 LOG(VB_JOBQUEUE, LOG_NOTICE,
"File is a MythTV recording.");
225 if (!tempDir.endsWith(
"/"))
230 if (a->
type ==
"Recording")
240 inFile.replace(
"\'",
"\\\'");
241 inFile.replace(
"\"",
"\\\"");
242 inFile.replace(
"`",
"\\`");
244 QString outFile = tempDir +
"work/file.xml";
247 QString command = QString(
"mytharchivehelper --getfileinfo --infile \"%1\" "
248 "--outfile \"%2\" --method %3")
249 .arg(inFile, outFile, QString::number(lenMethod));
252 command +=
" --quiet";
258 QDomDocument doc(
"mydocument");
260 if (!
file.open(QIODevice::ReadOnly))
263 if (!doc.setContent( &
file ))
271 QDomElement docElem = doc.documentElement();
272 QDomNodeList nodeList = doc.elementsByTagName(
"file");
273 if (nodeList.count() < 1)
275 QDomNode n = nodeList.item(0);
276 QDomElement e = n.toElement();
278 a->
duration = e.attribute(
"duration").toInt();
279 a->
cutDuration = e.attribute(
"cutduration").toInt();
282 nodeList = doc.elementsByTagName(
"video");
283 if (nodeList.count() < 1)
285 n = nodeList.item(0);
299 if (dialog->Create())
332 float len = (float) length / 3600;
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
#define ENO
This can be appended to the LOG args with "+".
#define GENERIC_EXIT_OK
Exited with no error.
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
QVariant value(int i) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
QString getTempDirectory(bool showError)
QString formatSize(int64_t sizeKB, int prec)
void showWarningDialog(const QString &msg)
void SetPathname(const QString &pn)
bool getFileDetails(ArchiveItem *a)
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
void checkTempDirectory()
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
ProgramInfo * getProgramInfoForFile(const QString &inFile)
EncoderProfile * encoderProfile
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Holds information on recordings and videos.
Dialog asking for user confirmation. Ok and optional Cancel button.
QString GetPlaybackURL(bool checkMaster=false, bool forceCheckLocal=false)
Returns filename or URL to be used to play back this recording.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
std::vector< ArchiveDestination > ArchiveDestinations
MythMainWindow * GetMythMainWindow(void)
void recalcItemSize(ArchiveItem *item)
MythScreenStack * GetStack(const QString &Stackname)
bool logPropagateQuiet(void)
Check if we are propagating a "--quiet".
@ kMSDontDisableDrawing
avoid disabling UI drawing
void SaveSetting(const QString &key, int newValue)
QString getBaseName(const QString &filename)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
bool extractDetailsFromFilename(const QString &inFile, QString &chanID, QString &startTime)
QString GetSetting(const QString &key, const QString &defaultval="")
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.