Problem in saving fetched sound/images in Parley
Xin Huang
xinhuang.abc at gmail.com
Tue Mar 14 08:29:51 UTC 2017
Sure. I'd be happy to.
On Mon, 13 Mar 2017 at 4:44 PM Albert Astals Cid <aacid at kde.org> wrote:
> El dilluns, 6 de març de 2017, a les 15:29:00 CET, Xin Huang va escriure:
> > Hi All,
> >
> > When I am using Parley, I find that the FetchSound plugin has some
> > problems. I am using Ubuntu 16.10 and everything from the official
> package
> > repository. (I noticed there are some update, but the problem seems
> still)
> >
> >
> > 1. The mwclient package, used by wikitionary, requires to be upgraded
> since
> > Wikipedia deprecated API via http request. (should be https)
> >
> > After upgrading mwclient, an extra package request_oauthlib is also
> > required. Because mwclient is distributed by source code, it might be
> > required adding request_oauthlib source. (Or adding by using pip
> > dependencies?)
>
> Yes, i guess mwclient should be updated and request_oauthlib "added" if
> it's a
> dependency. Can you work on a patch for that?
>
> Cheers,
> Albert
>
>
> > 2. After mwclient is upgraded, there is a problem during saving sound
> file
> > url/path in keduvockvtml2writer.
> >
> > ( The code on GitHub can be found here: https://github.com/KDE/
> > libkeduvocdocument/blob/ddb743b7e312e69d7f1eee9a3f4c25
> > ef8031b27b/keduvocdocument/keduvockvtml2writer.cpp#L549 )
> >
> > bool KEduVocKvtml2Writer::writeTranslation( QDomElement
> > &translationElement, KEduVocTranslation* translation )
> > {
> > // ...
> > // sound
> > if ( !translation->soundUrl().isEmpty() ) {
> > QString urlString;
> > qDebug() << "soundUrl" << translation->soundUrl();
> > if (
> > KIO::upUrl(m_doc->url().adjusted(QUrl::RemoveFilename)).isParentOf(
> > translation->soundUrl()) ) {
> > // try to save as relative url
> > urlString = m_doc->url().toString(QUrl::RemoveFilename) +
> '/' +
> > translation->soundUrl().toString(); // <------------ HERE
> > } else {
> > urlString = translation->soundUrl().url();
> > }
> > qDebug() << "urlString" << urlString;
> > translationElement.appendChild( newTextElement( KVTML_SOUND,
> > urlString ) );
> > }
> >
> > Notice the line marked: The soundUrl of a translation parley passed in is
> > "file:///path/to/kvtml/kvtmlfilename_files/File:En-us-Word.ogg", and the
> > m_doc->url() is "file:///path/to/kvtml/kvtmlfilename.kvtml". By the logic
> > saving as relative url, the result will be "file:///path/to/kvtml/file://
> > /path/to/kvtml/kvtmlfilename_files/Files:En-us-word.ogg".
> >
> > To fix the saving to relative url, the code should be:
> >
> > QDir dir(m_doc->url().adjusted(QUrl::RemoveFilename).
> > toLocalFile());
> > qDebug() << m_doc->url().toString(QUrl::RemoveFilename);
> > urlString = dir.relativeFilePath(translation->soundUrl().
> > toLocalFile());
> >
> > Similar code for saving image to relative path is also incorrect. (Lines
> > above saving sound)
> >
> >
> > I have submitted a patch (https://git.reviewboard.kde.org/r/129992/) for
> > the second issue. For the first issue requires update mwclient package, I
> > don't know what would be a proper solution.
> >
> > Thanks,
> > Xin Huang
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20170314/d4be023f/attachment-0001.html>
More information about the kde-edu
mailing list