Problem in saving fetched sound/images in Parley

Xin Huang xinhuang.abc at gmail.com
Tue Mar 7 01:07:00 UTC 2017


Just noticed that Parley doesn't play sound file given relative file path.
(Probably it because App working dir is not the same as kvtml doc path)
Given an absolute file path, after saving/reload the kvtml doc, it is
converted to a relative path.

Maybe when query the sound file path from kvtml doc, it should returns an
absolute path if the saved version is relative? Or this should be done on
Parley side?

Any thoughts?

On Mon, Mar 6, 2017 at 3:29 PM, Xin Huang <xinhuang.abc at gmail.com> wrote:

> 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?)
>
>
>
> 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/libkedu
> vocdocument/blob/ddb743b7e312e69d7f1eee9a3f4c25ef8031b27b/
> 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(translati
> on->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/20170306/726a6f38/attachment-0001.html>


More information about the kde-edu mailing list