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;
void recalcItemSize(ArchiveItem *item)
void checkTempDirectory()
bool getFileDetails(ArchiveItem *a)
void showWarningDialog(const QString &msg)
bool extractDetailsFromFilename(const QString &inFile, QString &chanID, QString &startTime)
QString getBaseName(const QString &filename)
std::vector< ArchiveDestination > ArchiveDestinations
ProgramInfo * getProgramInfoForFile(const QString &inFile)
QString getTempDirectory(bool showError)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
QVariant value(int i) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Dialog asking for user confirmation.
void SaveSetting(const QString &key, int newValue)
QString GetSetting(const QString &key, const QString &defaultval="")
MythScreenStack * GetStack(const QString &Stackname)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Holds information on recordings and videos.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
QString GetPlaybackURL(bool checkMaster=false, bool forceCheckLocal=false)
Returns filename or URL to be used to play back this recording.
void SetPathname(const QString &pn)
@ GENERIC_EXIT_OK
Exited with no error.
bool logPropagateQuiet(void)
Check if we are propagating a "--quiet".
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
@ kMSDontDisableDrawing
avoid disabling UI drawing
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
EncoderProfile * encoderProfile