[mythtv] Mythvideo and UTF8 filenames
Xavier Hervy
maxpower44 at tiscali.fr
Tue Jun 8 13:12:01 EDT 2004
I just try the last cvs version of mythvideo.
mythvideo become unuseable. Each time i go in video manager, mythvideo
duplicate entry for each filename which have special characters.
moreover special characters are not displayed correctly.
I submit a patch which resolve it for me, can somebody try it and apply
it if correct ?
You should delete all entries in videometadata and grab informations
again to have correct data.
Xavier
-------------- next part --------------
Index: mythvideo/mythvideo/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/main.cpp,v
retrieving revision 1.30
diff -u -r1.30 main.cpp
--- mythvideo/mythvideo/main.cpp 2 Jun 2004 22:52:04 -0000 1.30
+++ mythvideo/mythvideo/main.cpp 8 Jun 2004 15:52:54 -0000
@@ -311,7 +311,7 @@
{
while (query.next())
{
- QString name = QString::fromUtf8(query.value(0).toString());
+ QString name = query.value(0).toString();
if (name != QString::null)
{
if ((iter = video_files.find(name)) != video_files.end())
@@ -432,6 +432,7 @@
}
QString filename = fi->absFilePath();
+ filename = filename.utf8();
if (fi->isDir())
BuildFileList(db, filename, video_files, imageExtensions);
else
Index: mythvideo/mythvideo/metadata.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/metadata.cpp,v
retrieving revision 1.12
diff -u -r1.12 metadata.cpp
--- mythvideo/mythvideo/metadata.cpp 26 May 2004 19:58:03 -0000 1.12
+++ mythvideo/mythvideo/metadata.cpp 8 Jun 2004 15:52:56 -0000
@@ -110,7 +110,7 @@
if (query.isActive()){
if (query.numRowsAffected()>0){
query.next();
- category = query.value(0).toString();
+ category = QString::fromUtf8(query.value(0).toString());
}
}else{
cerr << "metadata.o : SELECT Failed : " << thequery << endl;
@@ -128,7 +128,7 @@
genres.clear();
if (query.isActive() && query.numRowsAffected()>1){
while(query.next()){
- genres.append(query.value(0).toString());
+ genres.append(QString::fromUtf8(query.value(0).toString()));
}
}
}
@@ -144,7 +144,7 @@
countries.clear();
if (query.isActive() && query.numRowsAffected()>1){
while(query.next()){
- genres.append(query.value(0).toString());
+ genres.append(QString::fromUtf8(query.value(0).toString()));
}
}
@@ -225,7 +225,7 @@
childID = query.value(11).toUInt();
browse = query.value(12).toBool();
playcommand = query.value(13).toString();
- category = query.value(14).toString();
+ category = QString::fromUtf8(query.value(14).toString());
// Genres
fillGenres(db);
@@ -278,7 +278,7 @@
"coverfile,inetref,browse) VALUES "
"(\"%s\",\"%s\",\"%s\",\"%s\",%d,%f,%d,\"%s\",%d,\"%s\","
"\"%s\", %d);",
- title.utf8().data(), director.utf8().data(),
+ QString::fromUtf8(title).utf8().data(), director.utf8().data(),
plot.utf8().data(), rating.utf8().data(), year,
userrating, length, sqlfilename.utf8().data(), showlevel,
sqlcoverfile.utf8().data(), inetref.utf8().data(),browse);
@@ -294,7 +294,8 @@
void Metadata::guessTitle()
{
- title = filename.right(filename.length() - filename.findRev("/") - 1);
+ QString tmp = filename.utf8();
+ title = tmp.right(tmp.length() - tmp.findRev("/") - 1);
title.replace(QRegExp("_"), " ");
title.replace(QRegExp("%20"), " ");
title = title.left(title.findRev("."));
@@ -338,7 +339,8 @@
plot.replace(QRegExp("\""), QString("\\\""));
rating.replace(QRegExp("\""), QString("\\\""));
playcommand.replace(QRegExp("\""), QString("\\\""));
- QString sqlfilename = filename;
+ QString sqlfilename = filename.utf8();
+
sqlfilename.replace(QRegExp("\""), QString("\\\""));
QString sqlcoverfile = coverfile;
Index: mythvideo/mythvideo/videofilter.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/videofilter.cpp,v
retrieving revision 1.2
diff -u -r1.2 videofilter.cpp
--- mythvideo/mythvideo/videofilter.cpp 24 May 2004 01:19:11 -0000 1.2
+++ mythvideo/mythvideo/videofilter.cpp 8 Jun 2004 15:53:06 -0000
@@ -238,7 +238,7 @@
while (a_query.next())
{
category_select->addItem(a_query.value(0).toInt(),
- a_query.value(1).toString());
+ QString::fromUtf8(a_query.value(1).toString()));
}
}
category_select->addItem(0,tr("Unknown"));
@@ -258,7 +258,7 @@
{
while (a_query.next())
{
- genre_select->addItem(a_query.value(0).toInt() ,a_query.value(1).toString());
+ genre_select->addItem(a_query.value(0).toInt() ,QString::fromUtf8(a_query.value(1).toString()));
}
}
genre_select->addItem(0,tr("Unknown"));
@@ -277,7 +277,7 @@
{
while(a_query.next())
{
- country_select->addItem(a_query.value(0).toInt(),a_query.value(1).toString());
+ country_select->addItem(a_query.value(0).toInt(),QString::fromUtf8(a_query.value(1).toString()));
}
}
country_select->addItem(0,tr("Unknown"));
Index: mythvideo/mythvideo/videomanager.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/videomanager.cpp,v
retrieving revision 1.31
diff -u -r1.31 videomanager.cpp
--- mythvideo/mythvideo/videomanager.cpp 22 May 2004 19:31:42 -0000 1.31
+++ mythvideo/mythvideo/videomanager.cpp 8 Jun 2004 15:53:10 -0000
@@ -485,8 +485,9 @@
while (true) {
while (proc.canReadLineStdout() || proc.canReadLineStderr()) {
if (proc.canReadLineStdout()) {
- ret += QString::fromLocal8Bit(proc.readLineStdout(),-1) + "\n";
- }
+ // ret += QString::fromLocal8Bit(proc.readLineStdout(),-1) + "test\n";
+ ret += proc.readLineStdout() + "\n";
+ }
if (proc.canReadLineStderr()) {
if (err == "") err = cmd + ": ";
err += QString::fromLocal8Bit(proc.readLineStderr(),-1) + "\n";
@@ -510,7 +511,9 @@
while (proc.canReadLineStdout() || proc.canReadLineStderr()) {
if (proc.canReadLineStdout()) {
- ret += QString::fromLocal8Bit(proc.readLineStdout(),-1) + "\n";
+// ret += QString::fromLocal8Bit(proc.readLineStdout(),-1) + "\n";
+ ret += QString::fromUtf8(proc.readLineStdout()+"test",-1) + "\n";
+//ret += proc.readLineStdout().utf8() + "\n";
}
if (proc.canReadLineStderr()) {
if (err == "") err = cmd + ": ";
@@ -529,6 +532,7 @@
ret = "#ERROR";
}
VERBOSE(VB_ALL, ret);
+
return ret;
}
@@ -552,7 +556,7 @@
// parse results
movieList.clear();
int count = 0;
- QStringList lines = QStringList::split('\n', results);
+ QStringList lines = QStringList::split('\n', QString::fromUtf8(results,-1));
for (QStringList::Iterator it = lines.begin();it != lines.end(); ++it) {
if ( (*it).at(0) == '#') // treat lines beg w/ # as a comment
continue;
@@ -833,6 +837,7 @@
if (m_list.count() > 0 && curitem)
{
+
QString title = curitem->Title();
QString filename = curitem->Filename();
QString director = curitem->Director();
@@ -1387,7 +1392,6 @@
void VideoManager::ResetCurrentItem()
{
QString coverFile = tr("No Cover");
-
curitem->guessTitle();
curitem->setCoverFile(coverFile);
curitem->setYear(1895);
@@ -1653,7 +1657,6 @@
void VideoManager::slotResetMeta()
{
cancelPopup();
-
ResetCurrentItem();
QString movieCoverFile = GetMoviePoster(QString("Local"));
if (movieCoverFile != "<NULL>")
More information about the mythtv-dev
mailing list