better docs and debug msg

This commit is contained in:
Fabrice Laporte 2016-04-14 08:31:55 +02:00
parent 58df77e2cb
commit 6cfc106b8a
2 changed files with 12 additions and 7 deletions

View file

@ -692,6 +692,7 @@ class LyricsPlugin(plugins.BeetsPlugin):
item.lyrics = lyrics
if write:
item.try_write()
print(lyrics)
item.store()
def get_lyrics(self, artist, title):
@ -717,7 +718,8 @@ class LyricsPlugin(plugins.BeetsPlugin):
to_language))
r = requests.get(url, headers=headers)
if r.status_code != 200:
self._log.debug(r.text)
self._log.debug('translation API error {}: {}', r.status_code,
r.text)
return text
translation = ET.fromstring(r.text.encode('utf8')).text
result = ''

View file

@ -38,8 +38,8 @@ configuration file. The available options are:
- **auto**: Fetch lyrics automatically during import.
Default: ``yes``.
- **bing_client_secret**: Your Bing Translation application password (to enable
on-the-fly translating)
- **bing_client_secret**: Your `Bing Translation application password`_
(to :ref:`lyrics-translation`)
- **bing_lang_from**: By default all lyrics with a language other than
``bing_lang_to`` are translated. Use a list of lang codes to restrict the set
of source languages to translate.
@ -122,7 +122,9 @@ After that, the lyrics plugin will fall back on other declared data sources.
.. _pip: http://www.pip-installer.org/
.. _BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/bs4/doc/
Activate on-the-fly translation
.. _lyrics-translation:
Activate On-the-Fly Translation
-------------------------------
Using the Bing Translation API requires `langdetect`_, which you can install
@ -131,9 +133,10 @@ using `pip`_ by typing::
pip install langdetect
You also need to register for a Microsoft Azure Marketplace free account and
to the `Microsoft Translator API`_.
Set the ``bing_client_secret`` configuration option to your registered
application password, alongside ``bing_lang_to`` target `language code`_.
to the `Microsoft Translator API`_. Follow the four steps process, specifically
at step 3 enter `beets`` as *Client ID* and copy the generated *Client secret*.
Paste it into your ``bing_client_secret`` configuration, alongside
``bing_lang_to`` target `language code`_.
.. _Microsoft Translator API: https://www.microsoft.com/en-us/translator/getstarted.aspx
.. _language code: https://msdn.microsoft.com/en-us/library/hh456380.aspx