diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e3954e..4cd437f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +0.3.7 +===== +* Automatic update of lyrics on song change, possible since bug 14786 was fixed: https://trac.videolan.org/vlc/ticket/14786 +* Save lyrics to TXT file, fixes #9 +* Drop "Refresh" functionality +* Esperanto translation +* Fix numerous translations +* Update template +* Update existing translations +* README: add explanation about Save Lyrics +* Increase VLC version requirement to 3 +* Linux and Windows support for saving lyrics, other variants of Unix such as macOS untested +* Update Italian translation + 0.3.6 ===== * Fix support for MetroLyrics diff --git a/README.md b/README.md index 3d6b695..27017c6 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ VLC Media Player lyrics extension. Supports MetroLyrics, Sonic Hits, Lyrics Mode Installation ------------- -Download installer for Windows: [install](https://github.com/Smile4ever/VLC-Lyrics-Finder/raw/master/windows-releases/lyricsfinder-0.3.6.exe) +For version 0.3.7 and later, VLC 3.0 or higher is required. The last version compatible with VLC 2.x is 0.3.6. -AUR package for Arch Linux: [vlc-extension-lyricsfinder-git](https://aur.archlinux.org/packages/vlc-extension-lyricsfinder-git) +* Download installer for Windows: [install 0.3.7 for VLC 3](https://github.com/Smile4ever/VLC-Lyrics-Finder/raw/master/windows-releases/lyricsfinder-0.3.7.exe) or [install 0.3.6 for VLC 2](https://github.com/Smile4ever/VLC-Lyrics-Finder/raw/master/windows-releases/lyricsfinder-0.3.6.exe) +* AUR package for Arch Linux: [vlc-extension-lyricsfinder-git](https://aur.archlinux.org/packages/vlc-extension-lyricsfinder-git) +* Installation steps for Linux and macOS: -Installation steps for Linux and OS X: - -1. Download [lyricsfinder.lua](https://raw.githubusercontent.com/Smile4ever/VLC-Lyrics-Finder/master/lyricsfinder.lua) (Use **File -> Save as** if necessary). +1. Download [lyricsfinder.lua 0.3.7 for VLC 3](https://raw.githubusercontent.com/Smile4ever/VLC-Lyrics-Finder/master/lyricsfinder.lua) or [lyricsfinder 0.3.6 for VLC 2](https://raw.githubusercontent.com/Smile4ever/VLC-Lyrics-Finder/d941cd0f9a29b042401b4cb4680f008c0e0dadb0/lyricsfinder.lua) (Use **File -> Save as** if necessary). 2. Move the file lyricsfinder.lua to **lua/extensions** inside your VLC folder. For example, **C:\Program Files\VideoLAN\VLC\lua\extensions\lyricsfinder.lua** 3. To install the language files, put them inside your VLC folder in the subdirectory **lua/extensions/lyricsfinder/locale**. For example, **C:\Program Files\VideoLAN\VLC\lua\extensions\lyricsfinder\locale** 3. Restart VLC or open **Tools -> Plugins and extensions** and hit **reload extensions**. @@ -34,7 +34,7 @@ Usage Other buttons: * Search with Google: open a new browser tab to look for lyrics -* Refresh: force refresh of metadata and look up the lyrics +* Save lyrics: save lyrics to a TXT file in /tmp or C:\Temp * Switch: artist and title wrongly guessed? Click this button to switch them. The artist text becomes the title text, the title text becomes the artist text. When you open Lyrics Finder, it will try to make an attempt to get the lyrics. This means opening Lyrics Finder is enough if you want to see the lyrics of only one song. @@ -48,7 +48,6 @@ Since version 0.3.0, this script supports intelligent guessing. This means that * Artist - Title (anything): the information between parenthesis is discarded * Artist-Title: also works without spaces before and after the hyphen - Wrong file names: * Title - Artist * File names that contain two hyphens, like "Artist - Title - Album name". There is one exception: artist names that contain a hyphen are valid. For example "A-ha - Stay On These Roads". diff --git a/locale/afr.xml b/locale/afr.xml index cc383f7..2da3827 100644 --- a/locale/afr.xml +++ b/locale/afr.xml @@ -1,7 +1,7 @@ Lirieke Nie gevind nie Lirieke van -by +by Kry lirieke Verfris Ruil om @@ -16,5 +16,6 @@ Verkeerde kunstenaar of titel. Lirieke nie gevind nie. Geen lied gelaai nie. +Bewaar lirieke diff --git a/locale/bul.xml b/locale/bul.xml index 9624b20..863404c 100644 --- a/locale/bul.xml +++ b/locale/bul.xml @@ -1,7 +1,7 @@ Текстове Не е намерен Текст на -от +от Получаване на текст Опресняване Превключване @@ -16,3 +16,4 @@ Неправилен изпълнтел или заглавие. Не е намерен текст. Не е заредена песен. +Запазване на текста diff --git a/locale/dut.xml b/locale/dut.xml index 53518b7..cd69d72 100644 --- a/locale/dut.xml +++ b/locale/dut.xml @@ -1,7 +1,7 @@ Songtekst Niet gevonden Songtekst van -door +door Songtekst opzoeken Verversen Omwisselen @@ -16,5 +16,6 @@ Incorrecte artiest of titel. Songtekst niet gevonden. Geen liedje geladen. +Songtekst bewaren \ No newline at end of file diff --git a/locale/eng.xml b/locale/eng.xml index 89d86b7..51d8a8f 100644 --- a/locale/eng.xml +++ b/locale/eng.xml @@ -1,7 +1,7 @@ Lyrics Not Found Lyrics of -by +by Get Lyrics Refresh Switch @@ -16,3 +16,4 @@ Incorrect artist or title. Lyrics not found. No song loaded. +Save Lyrics diff --git a/locale/epo.xml b/locale/epo.xml new file mode 100644 index 0000000..efc80f9 --- /dev/null +++ b/locale/epo.xml @@ -0,0 +1,21 @@ +Literoj +Ne Trovita +Literoj de +de +Akiru Literojn +Refreŝigu +Ŝaltu +Fermu +Serĉu uzanta Google +Akiru ĝisdatigojn +Titolo: +Artisto: +Fonto: +Nova kanto estis aldonita. Por ricevi la literojn, klaku Akiru Literojn. +Ŝarĝas.. +Artisto aŭ titolo estas malĝusta. +Literoj estas ne trovita. +Neniu kanto ŝarĝita. +Savi Literoj + + diff --git a/locale/fre.xml b/locale/fre.xml index c9ff896..bf214d9 100644 --- a/locale/fre.xml +++ b/locale/fre.xml @@ -16,5 +16,6 @@ Artiste ou titre incorrect. Paroles non trouvés. Aucune chanson chargé. +Enregistrer les paroles diff --git a/locale/ger.xml b/locale/ger.xml index 43bea91..d69caf3 100644 --- a/locale/ger.xml +++ b/locale/ger.xml @@ -1,7 +1,7 @@ Liedtext Nicht gefunden Liedtext von -von +von Liedtext anzeigen Neu laden Wechseln @@ -16,5 +16,6 @@ Falscher Künstler oder Titel. Liedtext nicht gefunden. Kein Lied geladen. +Liedtext speichern - \ No newline at end of file + diff --git a/locale/ita.xml b/locale/ita.xml index d87ba26..c148a7e 100644 --- a/locale/ita.xml +++ b/locale/ita.xml @@ -1,20 +1,22 @@ Testo Non trovato Testo di -da -Prendi testo -Rinfresca -Commuta +da +Ottieni testo +Aggiorna +Inverti Chiudi Cerca con Google -Prendi aggiornamenti +Ottieni aggiornamenti Titolo: Artista: Sorgente: -Nuova canzone caricata. Per prendere il testo, clicca Prendi testo. +La canzone è cambiata. Per prendere il testo, clicca 'Ottieni testo'. Caricamento.. Artista o Titolo incorretto. Testo non trovato. -Nessuna canzone caricata. +Nessuna canzone in riproduzione. +Salva i testo - \ No newline at end of file + + diff --git a/locale/pol.xml b/locale/pol.xml index 670c3b8..da80936 100644 --- a/locale/pol.xml +++ b/locale/pol.xml @@ -1,7 +1,7 @@ Napisy Nie znaleziono Napisy do -od +od Zdobądź napisy Odśwież Przełącz @@ -16,5 +16,6 @@ Niepoprawny artysta lub tytuł. Nie znaleziono napisów. No piosenka załadowany. +Zapisz napisy - \ No newline at end of file + diff --git a/locale/rus.xml b/locale/rus.xml index 5ead900..8a12b83 100644 --- a/locale/rus.xml +++ b/locale/rus.xml @@ -1,7 +1,7 @@ Текст песни Текст не найден Текст песни -- +- Загрузить Обновить Поменять местами @@ -16,5 +16,6 @@ Некорректное название или исполнитель. Текст песни не найден. песня не загружается +Сохранить текст - \ No newline at end of file + diff --git a/locale/spa.xml b/locale/spa.xml index 42674d8..3580b9a 100644 --- a/locale/spa.xml +++ b/locale/spa.xml @@ -1,7 +1,7 @@ Letra No encontrado Letra de -por +por Buscar letra Actualizar Cambiar @@ -16,5 +16,6 @@ Artista o título incorrecto. Letra no encontrada. Ninguna canción cargada. +Guardar letra diff --git a/locale/template/empty.xml b/locale/template/empty.xml index 033327a..7b10ff6 100644 --- a/locale/template/empty.xml +++ b/locale/template/empty.xml @@ -1,7 +1,7 @@ - + @@ -16,5 +16,6 @@ + -Translated by First name Last name \ No newline at end of file + diff --git a/locale/template/eng.txt b/locale/template/eng.txt index 1857741..05129cf 100644 --- a/locale/template/eng.txt +++ b/locale/template/eng.txt @@ -16,3 +16,4 @@ Loading.. Incorrect artist or title. Lyrics not found. No song loaded. +Save Lyrics diff --git a/locale/tur.xml b/locale/tur.xml index 0e27588..c2747c7 100644 --- a/locale/tur.xml +++ b/locale/tur.xml @@ -1,7 +1,7 @@ Sözler Bulunamadı Sözleri -tarafından +tarafından Sözleri Alın Yenileyin Geçin @@ -15,4 +15,7 @@ Yükleniyor... Geçersiz sanatçı ya da başlık. Söz bulunamadı. -Translated by OzancanKaratas96 +Hiçbir şarkı yüklü değil. +Şarkı Sözlerini Kaydet + + diff --git a/locale/ukr.xml b/locale/ukr.xml index 3eb7b4b..820e5d8 100644 --- a/locale/ukr.xml +++ b/locale/ukr.xml @@ -1,7 +1,7 @@ Слова пісні Не знайдено Слова пісні -написані +написані Шукати тексти пісень Відновити Змінити місцями @@ -16,3 +16,4 @@ Некоректний виконавець або назва. Текст не знайден пісня не завантажена +Зберегти текст diff --git a/lyricsfinder.lua b/lyricsfinder.lua index 19fc14b..a850dd9 100644 --- a/lyricsfinder.lua +++ b/lyricsfinder.lua @@ -54,7 +54,6 @@ --------- MOST SPACES = title -- FIXME: Title (extratitle) for Metro Lyrics -- FIXME: In another life, I would like to add acoustic fingerprinting --- FIXME: update lyrics automatically on song change (without crashes) dlg = nil title = nil @@ -225,18 +224,18 @@ local lang_os_to_iso = { -- VLC Extension Descriptor function descriptor() return { - title = "Lyrics Finder"; - version = "0.3.6"; - author = "rsyh93, alexxxnf, Smile4ever"; - url = 'https://github.com/Smile4ever/VLC-Lyrics-Finder'; - description = "
Lyrics Finder
" - .. "
Gets the lyrics for your favorite songs" - .. "
(Based on the script made by Jean-Philippe Andre)" - .. "
(Modified by Aleksey Maydokin)" - .. "
(Modified and translated by Geoffrey De Belie"; - shortdesc = "Lyrics Finder"; - capabilities = { "input-listener"; "meta-listener"; "playing-listener" } - } + title = "Lyrics Finder"; + version = "0.3.7"; + author = "rsyh93, alexxxnf, Smile4ever"; + url = 'https://github.com/Smile4ever/VLC-Lyrics-Finder'; + description = "
Lyrics Finder
" + .. "
Gets the lyrics for your favorite songs" + .. "
(Based on the script made by Jean-Philippe Andre)" + .. "
(Modified by Aleksey Maydokin)" + .. "
(Modified and translated by Geoffrey De Belie"; + shortdesc = "Lyrics Finder"; + capabilities = { "input-listener"; "meta-listener"; "playing-listener" } + } end -- Function triggered when the extension is activated @@ -247,6 +246,7 @@ function activate() if dlg then dlg:show() end + show_dialog() return true end @@ -272,11 +272,9 @@ function show_dialog() if langcode then --GPL code from VLsub (adapted) - if is_window_path(vlc.config.datadir()) then - --Windows + if get_platform() == "windows" then slash = "\\" else - --Unix slash = "/" end @@ -314,7 +312,8 @@ function show_dialog() dlg:add_label(translation["label_artist"], 1, 2, 1) artist = dlg:add_text_input(get_artist(), 2, 2, 3) - dlg:add_button(translation["button_refresh"], update_metas, 5, 1, 1) + dlg:add_button("Save lyrics", click_save, 5, 1, 1) + --dlg:add_button(translation["button_refresh"], update_metas, 5, 1, 1) --dlg:add_button("Lyrics Connect", lyricsconnect, 5, 2, 1) dlg:add_button(translation["button_switch"], click_switch, 5, 2, 1) @@ -471,6 +470,48 @@ function getenv_lang() end end +function click_save() + local path = "" + local platform = get_platform() + local filename = "" + local lyricsText = trim(cleanHTML(lyric:get_text())) + + if platform == "unix" then + path = "/tmp/" + end + + if platform == "windows" then + path = "C:\\Temp\\" + end + + filename = path .. "Lyrics " .. artist:get_text() .. " - " .. title:get_text() .. ".txt" + + vlc.msg.dbg("[Lyrics Finder] Platform is " .. platform); + vlc.msg.dbg("[Lyrics Finder] Filename is " .. filename); + vlc.msg.dbg("[Lyrics Finder] Text is " .. lyricsText); + + local lines = magiclines(lyricsText) + vlc.msg.dbg("[Lyrics Finder] Text is " .. lyricsText); + local firstLine = true + + for line in magiclines(lyricsText) do + if firstLine == false then + os.execute(string.format('echo "%s" >> "' .. filename .. '"', line)) + else + os.execute(string.format('echo "%s" > "' .. filename .. '"', line)) + firstLine = false + end + end + + if platform == "unix" then + os.execute(string.format('xdg-open "%s"', filename)) + end + + if platform == "windows" then + os.execute(string.format('start "" "%s"', filename)) + end +end + function click_switch() local title_local = title:get_text() title:set_text(artist:get_text()) @@ -502,7 +543,6 @@ function download_update() --local installed_version = descriptor()["version"] open_url("https://github.com/Smile4ever/VLC-Lyrics-Finder") - end function lyricsconnect() @@ -512,8 +552,8 @@ function lyricsconnect() local artistc = get_artist(current_song) local titlec = get_title(current_song) - artist:set_text(artistc); - title:set_text(titlec); + artist:set_text(artistc) + title:set_text(titlec) update_lyrics() end end @@ -1027,9 +1067,13 @@ function input_changed() else lyric:set_text(translation["message_newsong"]) dlg:set_title(translation["dialogtitle_normal"]) + update_metas() + return true end end else + dlg:set_title(translation["dialogtitle_normal"]) + --it's a different song local item = vlc.item or vlc.input.item() if not item then @@ -1037,8 +1081,9 @@ function input_changed() lyric:set_text(translation["message_nosong"]) else lyric:set_text(translation["message_newsong"]) + update_metas() + return true end - dlg:set_title(translation["dialogtitle_normal"]) end end @@ -1061,6 +1106,7 @@ end function meta_changed() -- triggered by available media input meta data? -- requires meta-listener + --update_metas() end function is_lyric_page(lyric_string) @@ -1379,3 +1425,50 @@ end function is_window_path(path) return string.match(path, "^(%a:\\).+$") end + +--Wrapper for platform detection +function get_platform() + if is_window_path(vlc.config.datadir()) then + return "windows" + else + return "unix" + end +end + +--https://stackoverflow.com/questions/19326368/iterate-over-lines-including-blank-lines +function magiclines(s) + if s:sub(-1)~="\n" then s=s.."\n" end + return s:gmatch("(.-)\n") +end + +--https://gist.github.com/HoraceBury/9001099 +function cleanHTML(html) + -- list of strings to replace (the order is important to avoid conflicts) + local cleaner = { + { "&", "&" }, -- decode ampersands + { "—", "-" }, -- em dash + { "’", "'" }, -- right single quote + { "“", "\"" }, -- left double quote + { "”", "\"" }, -- right double quote + { "–", "-" }, -- en dash + { " ", " " }, -- non-breaking space + { "
", "\n" }, -- all
tags whether terminated or not (


) become new lines + { "

", "\n" }, -- ends of paragraphs become new lines + { "

", "\n" }, -- begin of paragraphs become new lines + { "(%b<>)", "" }, -- all other html elements are completely removed (must be done last) + { "(<)", "" }, -- all other html elements are completely removed (must be done last) + { "\r", "\n" }, -- return carriage become new lines + { "[\n\n]+", "\n" }, -- reduce all multiple new lines with a single new line + { "^\n*", "" }, -- trim new lines from the start... + { "\n*$", "" }, -- ... and end + { "\n", "\r\n" }, -- new lines become \r\n + } + + -- clean html from the string + for i=1, #cleaner do + local cleans = cleaner[i] + html = string.gsub( html, cleans[1], cleans[2] ) + end + + return html +end diff --git a/nsis-installer/Setup.nsi b/nsis-installer/Setup.nsi index 94ee62e..685eed3 100644 --- a/nsis-installer/Setup.nsi +++ b/nsis-installer/Setup.nsi @@ -1,7 +1,7 @@ ;Product Info Name "VLC Lyrics Finder" !define PRODUCT "VLC Lyrics Finder" -!define VERSION "0.3.6" +!define VERSION "0.3.7" !include "MUI.nsh" !include x64.nsh diff --git a/windows-releases/lyricsfinder-0.3.7.exe b/windows-releases/lyricsfinder-0.3.7.exe new file mode 100644 index 0000000..f51db16 Binary files /dev/null and b/windows-releases/lyricsfinder-0.3.7.exe differ