Skip to content

Commit

Permalink
Merge pull request #184 from Ultraschall/4beta2
Browse files Browse the repository at this point in the history
4beta2
  • Loading branch information
rstockm authored Dec 29, 2019
2 parents e4be924 + 40eb200 commit 084da30
Show file tree
Hide file tree
Showing 60 changed files with 6,681 additions and 1,342 deletions.
167 changes: 16 additions & 151 deletions Scripts/ultraschall_edit_id3_tags.lua
Original file line number Diff line number Diff line change
@@ -1,181 +1,46 @@
--[[
################################################################################
#
# Copyright (c) 2014-2017 Ultraschall (http://ultraschall.fm)
#
#
# Copyright (c) 2014-2019 Ultraschall (http://ultraschall.fm)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#
################################################################################
]]

oldnotes=reaper.GetSetProjectNotes(0, false, "")
oldnotes=string.gsub(oldnotes, "\n", "\b")

-- Print Message to console (debugging)
function Msg(val)
reaper.ShowConsoleMsg(tostring(val).."\n")
if oldnotes=="" then
Date = os.date("*t")
oldnotes="\b\b\b"..Date.year
end

-- Used to escape "'s by toCSV
--function escapeCSV (s)
-- _, count = string.gsub(s, "\"", "\"")
-- if count==nil then count=0 end
-- if math.fmod(count,2)==1 then --if we have a odd number of " replace them with ""
-- if string.find(s, '["]') then
-- s = '"' .. string.gsub(s, '"', '""') .. '"'
-- end
-- elseif string.find(s,",")~=nil then
-- s="\""..s.."\""
-- end
-- return s
--end

function notes2csv ()
local csv = ""
local array = {}
local count=0
notes = reaper.GetSetProjectNotes(0, false, "")
for line in notes:gmatch"[^\n]*" do
count=count+1
csv = csv .. "," .. line --escapeCSV(line)
array[count]=line
end

retval= string.sub(csv, 2) -- remove first ","

return retval, count, array
end



function csv2lines (line)
title = line:match("(.-),")
artist= line:match(".-,(.-),")
album = line:match(".-,.-,(.-),")
year = line:match(".-,.-,.-,(.-),")
genre = line:match(".-,.-,.-,.-,(.-),")
comment = line:match(".-,.-,.-,.-,.-,(.*)")
--[[ pos=0
pos_old=1
clean=""
for i=1, 5,1 do
pos=string.find(result,",",pos_old)
substring=string.sub(line,pos_old,pos-1)
clean=clean..substring.."\n"
pos_old=pos+1
end
--check field 6
substring=string.sub(line,pos_old)
clean=clean..substring
]]
return title.."\n"..artist.."\n"..album.."\n"..year.."\n"..genre.."\n"..comment
end

function checkevencharacters(string,character)
local count=0
local even=true
for i=1, string.len(string) do
if string:sub(i,i)==character then
if even==true then even=false
else even=true
end
end
end
return even
end

--reaper.ShowConsoleMsg("") --clear console
dialog_ret_vals, count, dialog_retvals_array = notes2csv() --default values
--if olll==nil then return end

retval, result = reaper.GetUserInputs("Edit ID3 Podcast Metadata", 6, "Title (no comma allowed):,Artist (no comma allowed):,Podcast (no comma allowed):,Year (no comma allowed):,Genre (no comma allowed):,Comment:", dialog_ret_vals)
retval, result = reaper.GetUserInputs("Edit ID3 Podcast Metadata", 6, "Episode Title:,Author:,Podcast:,Year:,Podcast Category:,Description:,extrawidth=300, separator=\b", oldnotes)

count=0
temp=-1
old_pos=0
pos=0
if retval == true then
pos=result:match(".-,.-,.-,.-,.-,()")
firstvals=result:sub(1,pos-1)
restvals=result:sub(pos,-1)
pos=restvals:match(".-,()")
if pos~=nil then restvals="\""..restvals.."\"" end
if restvals:match("\"\".*\"\"")~=nil then restvals=restvals:sub(2,-2) end


even=checkevencharacters(firstvals:match(".-,"),"\"")
if even==false then firstvals=firstvals:match("(.-),").."\""..firstvals:match(".-(,.*)") end

even=checkevencharacters(firstvals:match(".-,(.-,)"),"\"")
if even==false then firstvals=firstvals:match("(.-,.-),").."\""..firstvals:match(".-,.-(,.*)") end

even=checkevencharacters(firstvals:match(".-,.-,(.-,)"),"\"")
if even==false then firstvals=firstvals:match("(.-,.-,.-),").."\""..firstvals:match(".-,.-,.-(,.*)") end

even=checkevencharacters(firstvals:match(".-,.-,.-,(.-,)"),"\"")
if even==false then firstvals=firstvals:match("(.-,.-,.-,.-),").."\""..firstvals:match(".-,.-,.-,.-(,.*)") end

even=checkevencharacters(firstvals:match(".-,.-,.-,.-,(.-,)"),"\"")
if even==false then firstvals=firstvals:match("(.-,.-,.-,.-,.-),").."\""..firstvals:match(".-,.-,.-,.-,.-(,.*)") end

even=checkevencharacters(restvals,"\"")
if even==false then restvals=restvals.."\"" end

notes = reaper.GetSetProjectNotes(0, true, csv2lines(firstvals..restvals)) -- write new notes
end
result=string.gsub(result, "\b", "\n")

--[[
if retval == true then
--step through field 1-5 and check if the numer of " is even. Add a " to the end if needed.
pos=0
pos_old=1
clean=""
for i=1, 5,1 do
pos=string.find(result,",",pos_old)
substring=string.sub(result,pos_old,pos-1)
_, count = string.gsub(substring, "\"", "\"")
if math.fmod(count,2)==1 then substring=substring.."\"" end
clean=clean..substring..","
pos_old=pos+1
end
--check field 6
substring=string.sub(result,pos_old)
_, count = string.gsub(substring, "\"", "\"")
if math.fmod(count,2)==1 then substring=substring.."\"" end
clean=clean..substring
result=clean
-- if more than "," 5 then escape the comment field (surround with ")
_, count = string.gsub(result, ",", ",")
if count>5 then
pos=0
for i=1, 5,1 do
pos=string.find(result,",",pos+1)
end
temp=string.sub(result,pos+1,-1)
if temp:match("\"\".*\"\"")~=nil then newresult=string.sub(result,1,pos)..temp:sub(2,-2)
else newresult=string.sub(result,1,pos)..string.sub(result,pos+1)
end
reaper.MB(newresult,result,0)
result=newresult
--reaper.MB(string.sub(result,pos+1,-1),"",0)
end
notes = reaper.GetSetProjectNotes(0, true, csv2lines(result)) -- write new notes
end
--]]
notes = reaper.GetSetProjectNotes(0, true, result) -- write new notes
end
4 changes: 2 additions & 2 deletions Scripts/ultraschall_export_assistant.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ else -- macOS

-- name = element type x y w h caption ...other params...
logo = GUI.Pic:new( 484,280, 80, 80, img_ratio, img_adress, runcommand, "_Ultraschall_Open_Project_Folder"),
label = GUI.Lbl:new( 50, 120+y_offset, "Export MP3/ m4a\nRender your Podcast to a MP3/ m4a File.\n\n\nChapter Markers\nYou may take a final look at your chapter markers.\n\n\nID3 Metadata\nUse the ID3 Editor to add metadata to your podcast.\n\n\nPodcast Episode Image:\nFound.\n\n\n\n\nFinalize MP3/ m4a\nHit the button and select your MP3/ m4a to finalize it\nwith metadata, chapters and episode image!", 0),
label = GUI.Lbl:new( 50, 120+y_offset, "Export MP3\nRender your Podcast to a MP3 File.\n\n\nChapter Markers\nYou may take a final look at your chapter markers.\n\n\nID3 Metadata\nUse the ID3 Editor to add metadata to your podcast.\n\n\nPodcast Episode Image:\nFound.\n\n\n\n\nFinalize MP3\nHit the button and select your MP3 to finalize it\nwith metadata, chapters and episode image!", 0),
label2 = GUI.Lbl:new( 30, 120+y_offset, "1.\n\n\n\n2.\n\n\n\n3.\n\n\n\n4.\n\n\n\n\n\n5.", 0),
label3 = GUI.Lbl:new( 30, 70+y_offset, "Follow these simple steps:", 0),
export = GUI.Btn:new( 430, 120+y_offset, 190, 40, "Export MP3", runcommand, "_Ultraschall_Render_Check"),
Expand All @@ -173,7 +173,7 @@ else -- macOS

-- name = element type x y w h caption ...other params...
-- logo = GUI.Pic:new( 374,178, 0, 0, img_ratio, img_adress),
label = GUI.Lbl:new( 50, 120+y_offset, "Export MP3/ m4a\nRender your Podcast to a MP3/ m4a File.\n\n\nChapter Markers\nYou may take a final look at your chapter markers.\n\n\nID3 Metadata\nUse the ID3 Editor to add metadata to your podcast.\n\n\nPodcast Episode Image\nJust put a square .jpg, .jpeg or .png image with the\nname 'cover.xyz' OR with the same name as your\nproject file (.RPP) in the project folder.\n\n\nFinalize MP3/ m4a\nHit the button and select your MP3/ m4a to finalize it\nwith metadata, chapters and episode image!", 0),
label = GUI.Lbl:new( 50, 120+y_offset, "Export MP3\nRender your Podcast to a MP3 File.\n\n\nChapter Markers\nYou may take a final look at your chapter markers.\n\n\nID3 Metadata\nUse the ID3 Editor to add metadata to your podcast.\n\n\nPodcast Episode Image\nJust put a square .jpg, .jpeg or .png image with the\nname 'cover.xyz' OR with the same name as your\nproject file (.RPP) in the project folder.\n\n\nFinalize MP3\nHit the button and select your MP3 to finalize it\nwith metadata, chapters and episode image!", 0),
label2 = GUI.Lbl:new( 30, 120+y_offset, "1.\n\n\n\n2.\n\n\n\n3.\n\n\n\n4.\n\n\n\n\n\n5.", 0),
label3 = GUI.Lbl:new( 30, 70+y_offset, "Follow these simple steps:", 0),
export = GUI.Btn:new( 430, 120+y_offset, 190, 40, "Export MP3", runcommand, "_Ultraschall_Render_Check"),
Expand Down
7 changes: 6 additions & 1 deletion Scripts/ultraschall_gui_lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1620,11 +1620,16 @@ function Btn:draw()
GUI.color("txt")
GUI.font(4)

if reaper.GetOS() == "OSX64" then
btn_offset = 3
else
btn_offset = 1
end

local str_w, str_h = gfx.measurestr(self.caption)
gfx.x = x + 1 * state + ((w - str_w) / 2) - 2
gfx.y = y + 1 * state + ((h - str_h) / 2) - 2
gfx.y = gfx.y + 3
gfx.y = gfx.y + btn_offset
gfx.drawstr(self.caption)

end
Expand Down
10 changes: 5 additions & 5 deletions Scripts/ultraschall_open_project_folder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Author URI: http://extremraym.com
* Repository: GitHub > X-Raym > EEL Scripts for Cockos REAPER
* Repository URI: https://github.com/X-Raym/REAPER-EEL-Scripts
* File URl:
* File URl:
* Licence: GPL v3
* Forum Thread: Scripts: Various
* Forum Thread URI: http://forum.cockos.com/showthread.php?p=1622146
Expand All @@ -21,7 +21,7 @@
+ Initial Release
--]]


--------------------------------------------------------
-- DEBUG
-- -----
Expand Down Expand Up @@ -69,19 +69,19 @@ function IsProjectSaved()

retval, project_path_name = reaper.EnumProjects(-1, "")
if project_path_name ~= "" then

dir = GetPath(project_path_name, separator)
--msg(name)
name = string.sub(project_path_name, string.len(dir) + 1)
name = string.sub(name, 1, -5)

name = name:gsub(dir, "")

--msg(name)
project_saved = true
return project_saved
else
display = reaper.ShowMessageBox("You need to save the project to execute this script.", "File Export", 1)
display = reaper.ShowMessageBox("You need to save the project to execute this script.", "Project Folder", 1)

if display == 1 then

Expand Down
4 changes: 2 additions & 2 deletions UserPlugins/ultraschall_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ end

if reaper.GetOS() == "Win32" or reaper.GetOS() == "Win64" then
ultraschall.Separator = "\\"
else
else
ultraschall.Separator = "/"
end
end

local info = debug.getinfo(1,'S');
--ultraschall.Script_Path = info.source:match[[^@?(.*[\/])[^\/]-$]]
Expand Down
Loading

0 comments on commit 084da30

Please sign in to comment.