Ticket #4990: mythnews_patch.patch

File mythnews_patch.patch, 3.8 KB (added by james@…, 4 years ago)
  • mythplugins/mythnews/mythnews/mythnews.cpp

     
    946946                if (!dir.exists()) 
    947947                     dir.mkdir(fileprefix); 
    948948 
    949                 fileprefix += "/MythNews"; 
     949                // Grabs the parent Site name and appends it to the fileprefix 
    950950 
    951                 dir = QDir(fileprefix); 
    952                 if (!dir.exists()) 
    953                     dir.mkdir(fileprefix); 
     951                fileprefix += "/MythNews/files/"; 
     952                fileprefix += article->parent(); 
     953                fileprefix.replace(" ", "_"); 
     954                 
     955                // Some seriously dodgy code to grab the file name of the media file to be downloaded 
     956                QString filename; 
    954957 
    955                 QString sFilename(fileprefix + "/newstempfile"); 
     958                filename = QRegExp::escape(article->title()); 
     959                /* QStringList qstr = QStringList::split("/", cmdURL); 
     960                        for ( QStringList::Iterator it = qstr.begin(); it != qstr.end(); ++it ) { 
     961                                filename = QRegExp::escape(*it); 
     962                        } */ 
    956963 
    957                 if (getHttpFile(sFilename, cmdURL)) 
    958                 { 
    959                     qApp->unlock(); 
    960                     playVideo(sFilename); 
    961                     qApp->lock(); 
    962                 } 
     964                filename.replace(" ","_"); 
     965                filename.replace("/","-"); // As per above, this ensures that there aren't any conflicts with linux file name formats 
     966                 
     967                QFile file(fileprefix + "/" + filename); 
     968                QString sFilename(fileprefix + "/" + filename); 
     969 
     970                if(!file.exists()) 
     971                { 
     972                        dir = QDir(fileprefix); 
     973                        if (!dir.exists()) 
     974                            dir.mkdir(fileprefix); 
     975 
     976         
     977                        cout << sFilename << endl; 
     978 
     979                        if (getHttpFile(sFilename, cmdURL)) 
     980                        { 
     981                            qApp->unlock(); 
     982                                playVideo(QRegExp::escape(sFilename)); 
     983                            qApp->lock(); 
     984                        } 
     985                } else { 
     986                        qApp->unlock(); 
     987                                playVideo(QRegExp::escape(sFilename)); 
     988                        qApp->lock(); 
     989                } 
     990 
     991 
    963992            } else { 
    964993                QString cmdUrl(article->articleURL()); 
    965994                cmdUrl.replace('\'', "%27"); 
     
    12071236    } 
    12081237    else 
    12091238    { 
     1239        /* This bit is causing me issues. Video and flash works fine, however audio files cause myth to lose the focus 
     1240           and the external player is launched but doesn't have the focus, so key presses aren't being passed on. 
     1241        */ 
    12101242        if (command_string.contains("%s")) 
     1243            //command_string = "mplayer "+filename; 
    12111244            command_string = command_string.replace(QRegExp("%s"), filename); 
    1212  
     1245                 
     1246        cout << command_string << endl; 
    12131247        myth_system(command_string); 
    12141248    } 
    12151249 
  • mythplugins/mythnews/mythnews/newsengine.cpp

     
    5555 
    5656} 
    5757 
     58const QString& NewsArticle::parent() 
     59{ 
     60        //Added this function to allow for media downloads 
     61 
     62        return m_parent->name(); 
     63} 
     64 
     65 
    5866NewsSite::NewsSite(const QString& name, 
    5967                   const QString& url, 
    6068                   const QDateTime& updated) 
  • mythplugins/mythnews/mythnews/newsengine.h

     
    5252    const QString& thumbnail() const { return m_thumbnail; } 
    5353    const QString& mediaURL() const { return m_mediaURL; } 
    5454    const QString& enclosure() const { return m_enclosure; } 
     55    const QString& parent(); 
     56    const QString& type() const {return m_enclosureType; } 
    5557 
    5658private: 
    5759