Ticket #5485: dirname

File dirname, 9.0 KB (added by Tony Lill <ajlill@…>, 17 years ago)

Patch against 0.21 mythtv

Line 
1Index: libs/libmythtv/programinfo.h
2===================================================================
3--- libs/libmythtv/programinfo.h (revision 17406)
4+++ libs/libmythtv/programinfo.h (working copy)
5@@ -21,7 +21,7 @@
6 mythtv/bindings/perl/MythTV.pm
7 mythtv/bindings/python/MythTV.py
8 */
9-#define NUMPROGRAMLINES 46
10+#define NUMPROGRAMLINES 47
11
12 typedef enum {
13 MARK_UNSET = -10,
14@@ -332,6 +332,7 @@
15 int chancommfree;
16
17 QString pathname;
18+ QString dirname;
19 long long filesize;
20 QString hostname;
21 QString storagegroup;
22Index: libs/libmythtv/programinfo.cpp
23===================================================================
24--- libs/libmythtv/programinfo.cpp (revision 17406)
25+++ libs/libmythtv/programinfo.cpp (working copy)
26@@ -189,6 +189,7 @@
27 chanOutputFilters = QDeepCopy<QString>(other.chanOutputFilters);
28
29 pathname = QDeepCopy<QString>(other.pathname);
30+ dirname = QDeepCopy<QString>(other.dirname);
31 storagegroup = QDeepCopy<QString>(other.storagegroup);
32 filesize = other.filesize;
33 hostname = QDeepCopy<QString>(other.hostname);
34@@ -339,6 +340,7 @@
35 INT_TO_LIST(audioproperties)
36 INT_TO_LIST(videoproperties)
37 INT_TO_LIST(subtitleType)
38+ STR_TO_LIST(dirname)
39 /* do not forget to update the NUMPROGRAMLINES defines! */
40 }
41
42@@ -452,6 +454,7 @@
43 INT_FROM_LIST(audioproperties)
44 INT_FROM_LIST(videoproperties)
45 INT_FROM_LIST(subtitleType)
46+ STR_FROM_LIST(dirname)
47
48 return true;
49 }
50@@ -865,7 +868,7 @@
51 "lastmodified,stars,previouslyshown,originalairdate, "
52 "hostname,recordid,transcoder,playgroup, "
53 "recorded.recpriority,progstart,progend,basename,recgroup, "
54- "storagegroup "
55+ "storagegroup, dirname "
56 "FROM recorded "
57 "LEFT JOIN channel "
58 "ON recorded.chanid = channel.chanid "
59@@ -936,6 +939,7 @@
60 proginfo->recpriority = query.value(22).toInt();
61
62 proginfo->pathname = QString::fromUtf8(query.value(25).toString());
63+ proginfo->dirname = QString::fromUtf8(query.value(28).toString());
64
65 return proginfo;
66 }
67@@ -1559,7 +1563,7 @@
68 {
69 // Check to see if the file exists locally
70 StorageGroup sgroup(storagegroup);
71- tmpURL = sgroup.FindRecordingFile(basename);
72+ tmpURL = sgroup.FindRecordingFile(basename,dirname);
73
74 if (tmpURL != "")
75 {
76@@ -1606,12 +1610,15 @@
77 *
78 * This method, of course, only works if a recording has been scheduled
79 * and started.
80+ *
81+ * The sheduler sticks the best dir in pathname, then this function replces it
82+ * with the basename to store it, then puts the full pathname.
83 *
84 * \param ext File extension for recording
85 */
86 void ProgramInfo::StartedRecording(QString ext)
87 {
88- QString dirname = pathname;
89+ dirname = pathname;
90
91 if (!record)
92 {
93@@ -1727,7 +1734,7 @@
94 " programid, stars, previouslyshown, originalairdate, "
95 " findid, transcoder, playgroup, recpriority, "
96 " basename, progstart, progend, profile, "
97- " duplicate, storagegroup) "
98+ " duplicate, storagegroup, dirname) "
99 "VALUES"
100 " (:CHANID, :STARTS, :ENDS, :TITLE, "
101 " :SUBTITLE, :DESC, :HOSTNAME, :CATEGORY, "
102@@ -1735,7 +1742,7 @@
103 " :PROGRAMID,:STARS, :REPEAT, :ORIGAIRDATE, "
104 " :FINDID, :TRANSCODER, :PLAYGROUP, :RECPRIORITY, "
105 " :BASENAME, :PROGSTART, :PROGEND, :PROFILE, "
106- " 0, :STORGROUP) "
107+ " 0, :STORGROUP, :DIRNAME) "
108 );
109
110 if (pg->rectype == kOverrideRecord)
111@@ -1767,6 +1774,7 @@
112 query.bindValue(":PLAYGROUP", pg->playgroup.utf8());
113 query.bindValue(":RECPRIORITY", schd->getRecPriority());
114 query.bindValue(":BASENAME", pg->pathname);
115+ query.bindValue(":DIRNAME", pg->dirname);
116 query.bindValue(":STORGROUP", pg->storagegroup.utf8());
117 query.bindValue(":PROGSTART", pg->startts);
118 query.bindValue(":PROGEND", pg->endts);
119@@ -4795,7 +4803,7 @@
120 "recorded.progend, recorded.stars, "
121 "recordedprogram.audioprop+0, recordedprogram.videoprop+0, "
122 "recordedprogram.subtitletypes+0, recorded.watched, "
123- "recorded.storagegroup "
124+ "recorded.storagegroup, recorded.dirname "
125 "FROM recorded "
126 "LEFT JOIN record ON recorded.recordid = record.recordid "
127 "LEFT JOIN channel ON recorded.chanid = channel.chanid "
128@@ -4921,6 +4929,7 @@
129 proginfo->recgroup = QString::fromUtf8(query.value(16).toString());
130 proginfo->playgroup = QString::fromUtf8(query.value(27).toString());
131 proginfo->storagegroup = QString::fromUtf8(query.value(36).toString());
132+ proginfo->dirname = QString::fromUtf8(query.value(37).toString());
133 proginfo->recstatus = rsRecorded;
134
135 if ((pSchedList != NULL) && (proginfo->recendts > rectime))
136Index: libs/libmyth/storagegroup.cpp
137===================================================================
138--- libs/libmyth/storagegroup.cpp (revision 17406)
139+++ libs/libmyth/storagegroup.cpp (working copy)
140@@ -115,12 +115,12 @@
141 }
142 }
143
144-QString StorageGroup::FindRecordingFile(QString filename)
145+QString StorageGroup::FindRecordingFile(QString filename, QString hint)
146 {
147 VERBOSE(VB_FILE, LOC + QString("FindRecordingFile: Searching for '%1'")
148 .arg(filename));
149
150- QString recDir = FindRecordingDir(filename);
151+ QString recDir = FindRecordingDir(filename, hint);
152 QString result = "";
153
154 if (!recDir.isEmpty())
155@@ -139,11 +139,21 @@
156 return result;
157 }
158
159-QString StorageGroup::FindRecordingDir(QString filename)
160+QString StorageGroup::FindRecordingDir(QString filename, QString hint)
161 {
162 QString result = "";
163 QFile checkFile("");
164
165+ if( ! hint.isEmpty() )
166+ {
167+ QString testFile = hint + "/" + filename;
168+ VERBOSE(VB_FILE, LOC + QString("FindRecordingDir: Checking hint '%1'")
169+ .arg(hint));
170+ checkFile.setName(testFile);
171+ if (checkFile.exists())
172+ return hint;
173+ }
174+
175 unsigned int curDir = 0;
176 while (curDir < m_dirlist.size())
177 {
178Index: libs/libmyth/storagegroup.h
179===================================================================
180--- libs/libmyth/storagegroup.h (revision 17406)
181+++ libs/libmyth/storagegroup.h (working copy)
182@@ -21,8 +21,8 @@
183 QStringList GetDirList(void) const
184 { return QDeepCopy<QStringList>(m_dirlist); }
185
186- QString FindRecordingFile(QString filename);
187- QString FindRecordingDir(QString filename);
188+ QString FindRecordingFile(QString filename, QString hint = "");
189+ QString FindRecordingDir(QString filename, QString hint = "");
190
191 QString FindNextDirMostFree(void);
192
193Index: programs/mythbackend/mainserver.cpp
194===================================================================
195--- programs/mythbackend/mainserver.cpp (revision 17406)
196+++ programs/mythbackend/mainserver.cpp (working copy)
197@@ -1128,7 +1128,7 @@
198 "recordedprogram.audioprop+0, recordedprogram.videoprop+0, "
199 "recordedprogram.subtitletypes+0, transcoded, "
200 "recorded.recpriority, watched, recorded.preserve, "
201- "recorded.storagegroup "
202+ "recorded.storagegroup, recorded.dirname "
203 "FROM recorded "
204 "LEFT JOIN record ON recorded.recordid = record.recordid "
205 "LEFT JOIN channel ON recorded.chanid = channel.chanid "
206@@ -1214,6 +1214,7 @@
207 }
208
209 proginfo->pathname = QString::fromUtf8(query.value(28).toString());
210+ proginfo->dirname = QString::fromUtf8(query.value(40).toString());
211
212 if (proginfo->hostname.isEmpty() || proginfo->hostname.isNull())
213 proginfo->hostname = gContext->GetHostName();
214Index: bindings/python/MythTV/MythTV.py
215===================================================================
216--- bindings/python/MythTV/MythTV.py (revision 17406)
217+++ bindings/python/MythTV/MythTV.py (working copy)
218@@ -45,7 +45,7 @@
219
220 BACKEND_SEP = '[]:[]'
221 PROTO_VERSION = 40
222-PROGRAM_FIELDS = 46
223+PROGRAM_FIELDS = 47
224
225 class MythTV:
226 """
227@@ -302,6 +302,7 @@
228 self.audio_props = data[43]
229 self.video_props = data[44]
230 self.subtitle_type = data[45]
231+ self.dirname = data[46]
232
233 if __name__ == '__main__':
234 banner = '\'m\' is a MythTV instance.'
235Index: bindings/perl/MythTV.pm
236===================================================================
237--- bindings/perl/MythTV.pm (revision 17406)
238+++ bindings/perl/MythTV.pm (working copy)
239@@ -98,7 +98,7 @@
240 # NUMPROGRAMLINES is defined in mythtv/libs/libmythtv/programinfo.h and is
241 # the number of items in a ProgramInfo QStringList group used by
242 # ProgramInfo::ToSringList and ProgramInfo::FromStringList.
243- our $NUMPROGRAMLINES = 46;
244+ our $NUMPROGRAMLINES = 47;
245
246 # Reasons a recording wouldn't be happening (from libs/libmythtv/programinfo.h)
247 our %RecStatus_Types = (