Ticket #6819: MetaSGs.diff
File MetaSGs.diff, 17.3 KB (added by , 15 years ago) |
---|
-
mythplugins/mythvideo/mythvideo/videodlg.cpp
27 27 #include <mythtv/libmythui/mythdialogbox.h> 28 28 #include <mythtv/libmythui/mythgenerictree.h> 29 29 #include <mythtv/libmythui/mythsystem.h> 30 #include <mythtv/libmyth/remotefile.h> 30 31 31 32 #include "videoscan.h" 32 33 #include "globals.h" … … 143 144 144 145 if (!error) 145 146 { 146 QFile dest_file(m_dest_file); 147 if (dest_file.exists()) 148 dest_file.remove(); 149 150 if (dest_file.open(QIODevice::WriteOnly)) 147 if (m_dest_file.startsWith("myth://")) 151 148 { 152 const QByteArray &data = m_data_buffer.data(); 153 qint64 size = dest_file.write(data); 154 if (size != data.size()) 149 RemoteFile *outFile = new RemoteFile(m_dest_file, true); 150 if (!outFile->isOpen()) 155 151 { 156 errorMsg = tr("Error writing data to file %1.") 157 .arg(m_dest_file); 152 VERBOSE(VB_IMPORTANT, 153 QString("RingBuffer::RingBuffer(): Failed to open " 154 "remote file (%1) for write. Does Coverart " 155 "Storage Group Exist?").arg(m_dest_file)); 156 delete outFile; 157 outFile = NULL; 158 158 m_error_state = esError; 159 159 } 160 else 161 { 162 off_t written = outFile->Write(m_data_buffer.data(), m_data_buffer.size()); 163 if (written != m_data_buffer.size()) 164 { 165 errorMsg = tr("Error writing data to file %1.") 166 .arg(m_dest_file); 167 m_error_state = esError; 168 } 169 } 160 170 } 161 171 else 162 172 { 163 errorMsg = tr("Error: file error '%1' for file %2"). 164 arg(dest_file.errorString()).arg(m_dest_file); 165 m_error_state = esError; 173 QFile dest_file(m_dest_file); 174 if (dest_file.exists()) 175 dest_file.remove(); 176 177 if (dest_file.open(QIODevice::WriteOnly)) 178 { 179 const QByteArray &data = m_data_buffer.data(); 180 qint64 size = dest_file.write(data); 181 if (size != data.size()) 182 { 183 errorMsg = tr("Error writing data to file %1.") 184 .arg(m_dest_file); 185 m_error_state = esError; 186 } 187 } 188 else 189 { 190 errorMsg = tr("Error: file error '%1' for file %2"). 191 arg(dest_file.errorString()).arg(m_dest_file); 192 m_error_state = esError; 193 } 166 194 } 167 195 } 168 196 … … 250 278 251 279 if (!error) 252 280 { 253 QFile dest_file(m_dest_file); 254 if (dest_file.exists()) 255 dest_file.remove(); 256 257 if (dest_file.open(QIODevice::WriteOnly)) 281 if (m_dest_file.startsWith("myth://")) 258 282 { 259 const QByteArray &data = m_data_buffer.data(); 260 qint64 size = dest_file.write(data); 261 if (size != data.size()) 283 RemoteFile *outFile = new RemoteFile(m_dest_file, true); 284 if (!outFile->isOpen()) 262 285 { 263 errorMsg = tr("Error writing data to file %1.") 264 .arg(m_dest_file); 286 VERBOSE(VB_IMPORTANT, 287 QString("RingBuffer::RingBuffer(): Failed to open " 288 "remote file (%1) for write. Does Fanart " 289 "Storage Group Exist?").arg(m_dest_file)); 290 delete outFile; 291 outFile = NULL; 265 292 m_error_state = fesError; 266 293 } 294 else 295 { 296 off_t written = outFile->Write(m_data_buffer.data(), m_data_buffer.size()); 297 if (written != m_data_buffer.size()) 298 { 299 errorMsg = tr("Error writing data to file %1.") 300 .arg(m_dest_file); 301 m_error_state = fesError; 302 } 303 } 267 304 } 268 305 else 269 306 { 270 errorMsg = tr("Error: file error '%1' for file %2"). 271 arg(dest_file.errorString()).arg(m_dest_file); 272 m_error_state = fesError; 307 QFile dest_file(m_dest_file); 308 if (dest_file.exists()) 309 dest_file.remove(); 310 311 if (dest_file.open(QIODevice::WriteOnly)) 312 { 313 const QByteArray &data = m_data_buffer.data(); 314 qint64 size = dest_file.write(data); 315 if (size != data.size()) 316 { 317 errorMsg = tr("Error writing data to file %1.") 318 .arg(m_dest_file); 319 m_error_state = fesError; 320 } 321 } 322 else 323 { 324 errorMsg = tr("Error: file error '%1' for file %2"). 325 arg(dest_file.errorString()).arg(m_dest_file); 326 m_error_state = fesError; 327 } 273 328 } 274 329 } 275 330 … … 357 412 358 413 if (!error) 359 414 { 360 QFile dest_file(m_dest_file); 361 if (dest_file.exists()) 362 dest_file.remove(); 363 364 if (dest_file.open(QIODevice::WriteOnly)) 415 if (m_dest_file.startsWith("myth://")) 365 416 { 366 const QByteArray &data = m_data_buffer.data(); 367 qint64 size = dest_file.write(data); 368 if (size != data.size()) 417 RemoteFile *outFile = new RemoteFile(m_dest_file, true); 418 if (!outFile->isOpen()) 419 { 420 VERBOSE(VB_IMPORTANT, 421 QString("RingBuffer::RingBuffer(): Failed to open " 422 "remote file (%1) for write. Does Banner " 423 "Storage Group Exist?").arg(m_dest_file)); 424 delete outFile; 425 outFile = NULL; 426 m_error_state = besError; 427 } 428 else 369 429 { 370 errorMsg = tr("Error writing data to file %1.") 371 .arg(m_dest_file); 372 m_error_state = besError; 430 off_t written = outFile->Write(m_data_buffer.data(), m_data_buffer.size()); 431 if (written != m_data_buffer.size()) 432 { 433 errorMsg = tr("Error writing data to file %1.") 434 .arg(m_dest_file); 435 m_error_state = besError; 436 } 373 437 } 374 438 } 375 439 else 376 440 { 377 errorMsg = tr("Error: file error '%1' for file %2"). 378 arg(dest_file.errorString()).arg(m_dest_file); 379 m_error_state = besError; 441 QFile dest_file(m_dest_file); 442 if (dest_file.exists()) 443 dest_file.remove(); 444 445 if (dest_file.open(QIODevice::WriteOnly)) 446 { 447 const QByteArray &data = m_data_buffer.data(); 448 qint64 size = dest_file.write(data); 449 if (size != data.size()) 450 { 451 errorMsg = tr("Error writing data to file %1.") 452 .arg(m_dest_file); 453 m_error_state = besError; 454 } 455 } 456 else 457 { 458 errorMsg = tr("Error: file error '%1' for file %2"). 459 arg(dest_file.errorString()).arg(m_dest_file); 460 m_error_state = besError; 461 } 380 462 } 381 463 } 382 464 … … 3342 3424 3343 3425 QString ext = QFileInfo(url.path()).suffix(); 3344 3426 QString dest_file; 3427 QString db_value; 3345 3428 3346 3429 if (metadata->GetSeason() > 0 || 3347 3430 metadata->GetEpisode() > 0) … … 3349 3432 // Name TV downloads so that they already work with the PBB 3350 3433 QString title = QString("%1 Season %2").arg(metadata->GetTitle()) 3351 3434 .arg(metadata->GetSeason()); 3352 dest_file = QString("%1/%2.%3").arg(fileprefix) 3353 .arg(title).arg(ext); 3435 if (!metadata->GetHost().isEmpty()) 3436 { 3437 QString combFileName = QString("%1.%2").arg(title).arg(ext); 3438 dest_file = GenRemoteFileURL("Coverart", metadata->GetHost(), 3439 combFileName); 3440 db_value = combFileName; 3441 } 3442 else 3443 { 3444 dest_file = QString("%1/%2.%3").arg(fileprefix) 3445 .arg(title).arg(ext); 3446 db_value = dest_file; 3447 } 3354 3448 } 3355 3449 else 3356 dest_file = QString("%1/%2.%3").arg(fileprefix) 3357 .arg(metadata->GetInetRef()).arg(ext); 3450 { 3451 if (!metadata->GetHost().isEmpty()) 3452 { 3453 QString combFileName = QString("%1.%2") 3454 .arg(metadata->GetInetRef()) 3455 .arg(ext); 3456 dest_file = GenRemoteFileURL("Coverart", metadata->GetHost(), 3457 combFileName); 3458 db_value = combFileName; 3459 } 3460 else 3461 { 3462 dest_file = QString("%1/%2.%3").arg(fileprefix) 3463 .arg(metadata->GetInetRef()).arg(ext); 3464 db_value = dest_file; 3465 } 3466 } 3358 3467 3359 3468 VERBOSE(VB_IMPORTANT, QString("Copying '%1' -> '%2'...") 3360 3469 .arg(url.toString()).arg(dest_file)); 3361 3470 3362 3471 CoverDownloadProxy *d = 3363 3472 CoverDownloadProxy::Create(url, dest_file, metadata); 3364 metadata->SetCoverFile(d est_file);3473 metadata->SetCoverFile(db_value); 3365 3474 3366 3475 connect(d, SIGNAL(SigFinished(CoverDownloadErrorState, 3367 3476 QString, Metadata *)), … … 3449 3558 3450 3559 QString ext = QFileInfo(url.path()).suffix(); 3451 3560 QString dest_file; 3561 QString db_value; 3452 3562 3453 3563 if (metadata->GetSeason() > 0 || 3454 3564 metadata->GetEpisode() > 0) 3455 { 3456 // Name TV downloads so that they already work with the PBB 3565 { 3566 // Name TV downloads so that they already work with the PBB 3457 3567 QString title = QString("%1 Season %2").arg(metadata->GetTitle()) 3458 3568 .arg(metadata->GetSeason()); 3459 dest_file = QString("%1/%2.%3").arg(fileprefix) 3460 .arg(title).arg(ext); 3569 if (!metadata->GetHost().isEmpty()) 3570 { 3571 QString combFileName = QString("%1.%2").arg(title).arg(ext); 3572 dest_file = GenRemoteFileURL("Fanart", metadata->GetHost(), 3573 combFileName); 3574 db_value = combFileName; 3575 } 3576 else 3577 { 3578 dest_file = QString("%1/%2.%3").arg(fileprefix) 3579 .arg(title).arg(ext); 3580 db_value = dest_file; 3581 } 3461 3582 } 3462 3583 else 3463 dest_file = QString("%1/%2.%3").arg(fileprefix) 3464 .arg(metadata->GetInetRef()).arg(ext); 3584 { 3585 if (!metadata->GetHost().isEmpty()) 3586 { 3587 QString combFileName = QString("%1.%2") 3588 .arg(metadata->GetInetRef()) 3589 .arg(ext); 3590 dest_file = GenRemoteFileURL("Fanart", metadata->GetHost(), 3591 combFileName); 3592 db_value = combFileName; 3593 } 3594 else 3595 { 3596 dest_file = QString("%1/%2.%3").arg(fileprefix) 3597 .arg(metadata->GetInetRef()).arg(ext); 3598 db_value = dest_file; 3599 } 3600 } 3465 3601 3466 3602 VERBOSE(VB_IMPORTANT, QString("Copying '%1' -> '%2'...") 3467 3603 .arg(url.toString()).arg(dest_file)); 3468 3604 3469 3605 FanartDownloadProxy *d = 3470 3606 FanartDownloadProxy::Create(url, dest_file, metadata); 3471 metadata->SetFanart(d est_file);3607 metadata->SetFanart(db_value); 3472 3608 3473 3609 connect(d, SIGNAL(SigFinished(FanartDownloadErrorState, 3474 3610 QString, Metadata *)), … … 3556 3692 3557 3693 QString ext = QFileInfo(url.path()).suffix(); 3558 3694 QString dest_file; 3695 QString db_value; 3559 3696 3560 3697 if (metadata->GetSeason() > 0 || 3561 3698 metadata->GetEpisode() > 0) … … 3563 3700 // Name TV downloads so that they already work with the PBB 3564 3701 QString title = QString("%1 Season %2").arg(metadata->GetTitle()) 3565 3702 .arg(metadata->GetSeason()); 3566 dest_file = QString("%1/%2.%3").arg(fileprefix) 3567 .arg(title).arg(ext); 3703 if (!metadata->GetHost().isEmpty()) 3704 { 3705 QString combFileName = QString("%1.%2").arg(title).arg(ext); 3706 dest_file = GenRemoteFileURL("Banners", metadata->GetHost(), 3707 combFileName); 3708 db_value = combFileName; 3709 } 3710 else 3711 { 3712 dest_file = QString("%1/%2.%3").arg(fileprefix) 3713 .arg(title).arg(ext); 3714 db_value = dest_file; 3715 } 3568 3716 } 3569 3717 else 3570 dest_file = QString("%1/%2.%3").arg(fileprefix) 3571 .arg(metadata->GetInetRef()).arg(ext); 3718 { 3719 if (!metadata->GetHost().isEmpty()) 3720 { 3721 QString combFileName = QString("%1.%2") 3722 .arg(metadata->GetInetRef()) 3723 .arg(ext); 3724 dest_file = GenRemoteFileURL("Banners", metadata->GetHost(), 3725 combFileName); 3726 db_value = combFileName; 3727 } 3728 else 3729 { 3730 dest_file = QString("%1/%2.%3").arg(fileprefix) 3731 .arg(metadata->GetInetRef()).arg(ext); 3732 db_value = dest_file; 3733 } 3734 } 3572 3735 3573 3736 VERBOSE(VB_IMPORTANT, QString("Copying '%1' -> '%2'...") 3574 3737 .arg(url.toString()).arg(dest_file)); 3575 3738 3576 3739 BannerDownloadProxy *d = 3577 3740 BannerDownloadProxy::Create(url, dest_file, metadata); 3578 metadata->SetBanner(d est_file);3741 metadata->SetBanner(db_value); 3579 3742 3580 3743 connect(d, SIGNAL(SigFinished(BannerDownloadErrorState, 3581 3744 QString, Metadata *)),