Go to the documentation of this file.
9 #include <QCoreApplication>
11 #include <QDomDocument>
29 QT_TRANSLATE_NOOP(
"SelectDestination",
"Single Layer DVD"),
30 QT_TRANSLATE_NOOP(
"SelectDestination",
"Single Layer DVD (4,482 MB)"),
33 QT_TRANSLATE_NOOP(
"SelectDestination",
"Dual Layer DVD"),
34 QT_TRANSLATE_NOOP(
"SelectDestination",
"Dual Layer DVD (8,964 MB)"),
37 QT_TRANSLATE_NOOP(
"SelectDestination",
"DVD +/- RW"),
38 QT_TRANSLATE_NOOP(
"SelectDestination",
"Rewritable DVD"),
41 QT_TRANSLATE_NOOP(
"SelectDestination",
"File"),
42 QT_TRANSLATE_NOOP(
"SelectDestination",
"Any file accessable from your filesystem."),
50 if (tempDir ==
"" && showError)
52 ShowOkPopup(QCoreApplication::translate(
"(ArchiveUtils)",
53 "Cannot find the MythArchive work directory.\n"
54 "Have you set the correct path in the settings?"));
61 if (!tempDir.endsWith(
"/"))
73 QString logDir = tempDir +
"logs";
74 QString configDir = tempDir +
"config";
75 QString workDir = tempDir +
"work";
82 if( chmod(qPrintable(tempDir), 0777) != 0 )
83 LOG(VB_GENERAL, LOG_ERR,
84 "Failed to change permissions on archive directory: " +
ENO);
87 dir.setPath(workDir);;
91 if( chmod(qPrintable(workDir), 0777) != 0 )
93 LOG(VB_GENERAL, LOG_ERR,
94 "Failed to change permissions on archive work directory: " +
103 if( chmod(qPrintable(logDir), 0777) != 0 )
105 LOG(VB_GENERAL, LOG_ERR,
106 "Failed to change permissions on archive log directory: " +
110 dir.setPath(configDir);;
113 dir.mkdir(configDir);
114 if( chmod(qPrintable(configDir), 0777) != 0 )
116 LOG(VB_GENERAL, LOG_ERR,
117 "Failed to change permissions on archive config directory: " +
126 int pos =
filename.lastIndexOf(
'/');
134 QString &chanID, QString &startTime)
136 LOG(VB_JOBQUEUE, LOG_INFO,
"Extracting details from: " + inFile);
141 query.
prepare(
"SELECT chanid, starttime FROM recorded "
142 "WHERE basename = :BASENAME");
147 chanID = query.
value(0).toString();
148 startTime= query.
value(1).toString();
152 LOG(VB_JOBQUEUE, LOG_ERR,
153 QString(
"Cannot find details for %1").arg(inFile));
157 LOG(VB_JOBQUEUE, LOG_INFO,
158 QString(
"chanid: %1 starttime:%2 ").arg(chanID, startTime));
171 if (bIsMythRecording)
173 uint chanid = chanID.toUInt();
191 LOG(VB_JOBQUEUE, LOG_NOTICE,
"File is not a MythTV recording.");
195 LOG(VB_JOBQUEUE, LOG_NOTICE,
"File is a MythTV recording.");
205 if (!tempDir.endsWith(
"/"))
210 if (a->
type ==
"Recording")
220 inFile.replace(
"\'",
"\\\'");
221 inFile.replace(
"\"",
"\\\"");
222 inFile.replace(
"`",
"\\`");
224 QString outFile = tempDir +
"work/file.xml";
227 QString command = QString(
"mytharchivehelper --getfileinfo --infile \"%1\" "
228 "--outfile \"%2\" --method %3")
229 .arg(inFile, outFile, QString::number(lenMethod));
232 command +=
" --quiet";
238 QDomDocument doc(
"mydocument");
240 if (!
file.open(QIODevice::ReadOnly))
243 if (!doc.setContent( &
file ))
251 QDomElement docElem = doc.documentElement();
252 QDomNodeList nodeList = doc.elementsByTagName(
"file");
253 if (nodeList.count() < 1)
255 QDomNode n = nodeList.item(0);
256 QDomElement e = n.toElement();
258 a->
duration = e.attribute(
"duration").toInt();
259 a->
cutDuration = e.attribute(
"cutduration").toInt();
262 nodeList = doc.elementsByTagName(
"video");
263 if (nodeList.count() < 1)
265 n = nodeList.item(0);
279 if (dialog->Create())
312 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 "+".
@ 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)
void showWarningDialog(const QString &msg)
void SetPathname(const QString &pn)
bool getFileDetails(ArchiveItem *a)
@ GENERIC_EXIT_OK
Exited with no error.
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.