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 @@
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 = "
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" }, -- 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