Author Topic: Search box ignores text in newline.  (Read 551 times)

SpirosG

  • Jr. Member
  • **
  • Posts: 92
When you try to paste text that contains two lines, Musicbee prefers to ignore the second line.

Example

Code
Where You Are
John Summit & Hayla

Any chance to change that behavior. so when you paste any text containing two lines, Musicbee will automatically transform that to something similar as the text below?

Code
Where You Are John Summit & Hayla

hiccup

  • Sr. Member
  • ****
  • Posts: 7865
When you try to paste text that contains two lines, Musicbee prefers to ignore the second line.
That makes perfect sense to me. Why should a search bar that is designed to only have a couple of search terms entered be able to manage text blocks?

As discussed before, you have a very specific use case that poses issues for you that were never raised by, or posed a problem for any other user before. (that I can recall)
Raising this as a software bug doesn't seem right to me.

As suggested before, you could check out AutoHotkey, or some clipboard manager like Ditto, CopyX, etc.
They can all be configured to do what you are aiming for.

SpirosG

  • Jr. Member
  • **
  • Posts: 92
I was thinking it was some kind of a bug, because i didn't have this kind of problem when i was pasting the same text to firefox for example.
I get why a text editor would copy the text at it's exact form, but i thought it would be more logical for Musicbee to behave the same as Firefox or even Spotify.

I know that my use case is a bit too niche but i use Musicbee as my DJ Library, and reducing the time i spend in Musicbee to prepare my sets or even the time i spend during my sets is really important and these micro problems that i have are costing time to me.

I found a solution, as long as i copy texts within Firefox. I use an add-on [copy plain text] where you have the ability to find & replace.

Code
FIND:/\r?\n/
REPLACE:" "

Zak

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 2459
Without having tried it, it's probably easy to set up an AutoHotKey script that does the replacement when you paste text rather than copy it.
Bee excellent to each other...

SpirosG

  • Jr. Member
  • **
  • Posts: 92
Tried multiple variations to do that only when i paste texts to Musicbee using the default Windows keys or Right click+paste, but i couldn't make it work.

For the moment, i use this Code with AHK to alter what i copy to clipboard.


Code
#NoEnv
#SingleInstance Force
#Persistent

OnClipboardChange("ReplaceClipboardText")

ReplaceClipboardText(Type) {
    if (Type != 1) {
        return
    }
    
    clipboard := RegExReplace(clipboard, "(feat\.|ft\.|&|\R|, )", " ")
    clipboard := RegExReplace(clipboard, "\s+", " ") ; replace extra spaces with one
}


Code that works only when you paste texts to MusicBee

Code
#Requires AutoHotkey v2.0

#HotIf WinActive('ahk_exe MusicBee.exe')
^v:: {  ; ^v = Paste replaced text
 Static replace := ['feat.', 'ft.', '&', '/\r?\n/']
 txt := A_Clipboard
 For each, item in replace
  txt := StrReplace(txt, item, ' ')
 SendText Trim(RegExReplace(txt, '\h+', ' '))
}
#HotIf

You can replace ^v with something else to change the Hotkey.


This works with Ctrl+V but not with Right click and Paste command from within the context menu.
I only need  to solve the last part now.


Updated, and i now i think i have the script i needed.


The script is using the mouse wheel button (middle click) to select all and then paste the text while it replaces any unwanted string.

You may need to change the coordinates on "Send "{Click..."

Code
#Requires AutoHotkey v2.0

#HotIf WinActive('ahk_exe MusicBee.exe')

MButton:: { ; Middle mouse button = Paste replaced text
 Send "{Click 1585 47}"
 Send "^{a}"
 Static replace := ['feat\.', 'ft\.', '&', '\R', ', ', ' - ', ' – ', ' — ', ' vs. ', ' Featuring ']
 txt := A_Clipboard
 txt := RegExReplace(txt, "\([^()]*\)", "")  ; Remove text within parentheses
 For each, item in replace
 txt := StrReplace(txt, item, ' ')
 SendText Trim(RegExReplace(txt, '\h+', ' '))
Return
}
#HotIf

Last Edit: April 22, 2023, 12:32:18 AM by SpirosG