Another quick question (RE: copying portions of a tag field)


#1

I know I've seen this somewhere on this forum, but I've spent an hour searching the FAQ and forums and cannot find it. Does anyone know where there is a script for extrapolating the 'lyricists' or 'written by' fields from Discogs?

I have Pone's Discog's script and have the additional credits written to the 'comment' field. I've seen a script that presents the comment field by role and by person, but I would like to extract all the "written by" or lyricist credits to the composer field specifically.

Does anyone have a script or bookmark to a script that does this kind of thing? As I said, I thought I've seen it on here somewhere but cannot seem to locate it.


#2

To add to my post:

Basically I want to take a subset of data written into the "comments" field (specifically 'written-by' data gathered from Pone's Discog's script) and copy it to the composer field.

Here is a post that deals with copying...

Regular Expressions

...but I only want a portion of the data.

The typical discogs additional credits format might have something like:

Keyboards - Person 1, Person 2
Producer - Person 1, Person 2
Written-by - Person 1, Person 2, Person 3

I just want to take the "Written-by" data and copy the people over to the "composer" field. I can separate them with a semi-colon using an additional action.

I thought I saw this kind of a post somewhere, but I still cannot find it.


#3

Not sure what your definition of "script" is, maybe you mean Action?

Well try this action:
Format value on COMPOSER
String:
$regexp(%comment%,'.^Written-by - (.+?)$.',$1)


#4

Thanks, dano. I realized it went to mixartist instead of comment, but nonetheless it did copy from mixartist but it didn't extract anything. There seem to be two types for Discogs: "Written-by: " and "Lyrics By: "

I used your format string for both and neither extrapolated the portions. It just copied the mixartist field to composer field exactly as it was written.


#5

Your example said
"Written-by - "
and now it is
"Written-by: "

so simply adjust it.
And for Lyrics by, make a second action.


#6

I'm sorry I didn't make myself clear, but I already did adjust it as soon as I realized my mistake. It's not working even with the adjustments.


#7

What's the syntax of the mixartist field, multiple lines like in your example or everything in one line?


#8

It's everything in one line, seperated by ;
No ; if it is the last entry.


#9

It's everything in one line. Here's an example of one of the mixartist fields from an album I was experimenting with:

Backing Vocals: Lynette Koyana; Flute: David Wilczewski; Lyrics By: Nina Persson, Peter Svensson; Violin: Inga Zeppezauer, Maria Holm, Mattias Svensson, Åsa Häkansson


#10

Try this (can't check it at the moment):

$regexp(%mixartist%,'.(^|; )Written-by: (.+?)(;|$).',$2)

EDIT:
There was a typo at the regex. The "T", which you can see in your quote beneath, should not be there.


#11

This just about did the trick.

I tried this example with "lyrics by: " and this worked on all of them except the mixartist fields that only had lyrics as the only credits. In those cases, it had "lyrics by: " preceding the names. That's not a huge deal, though, as I could write an action to remove that.


#12

You no "written by" and "lyrics by" isn't the same thing. Writ.ten by is aut the music. So composer fits here. Lyrics by is about the lyrics, the text. Lyricist would be a better field here.
Also note that you can have both things for one song.
Another thing which is used quite often at discogs is "music by" which is quite the same as written by.


#13

I'm aware of that. To my knowledge, though, Windows Media Player (which is what I use as my library) does not support Lyricist field. They support the composer field alone, though I may be mistaken.


#14

hi folks,

my album tag looks like "word1 word2 word3 wordn". i'd like to write the first 2 or 3 words to a new field "label", leaving the album field as is.

thanks!


#15

i tried;

          $regexp(%album%,^(.+)\s(.+)$,$1)

that seems to describe the album tag in two subsets. everything before the final space & everything after. thus in the album tag "Firehouse '86 - K. Tubby" $1 would produce "Firehouse '86 - K." & $2 "Tubby".

i'd like to describe above album as;

        $1 = Firehouse
        $2 = '86
        $3 = -
        $4 = K.
        $5 = Tubby

back to the drawing board! thoughts & comments welcome.


#16

Yes, this is the non-gready approach of the parser.

So, if you tried to do it in several steps instead of just one, you might be closer:
Create actions that do the following:

First copy everything from ALBUM to LABEL
Then replace with regular expressions or the tag-tag-converter until there is only the number of words left that you want e.g. with a filter like
NOT %label% MATCHES "^.* .*$"


#17

thanks ohrenkino! i'll try that.


#18

Regarding the usage of regular espressions in Mp3tag it might help to think of a "word" as a sequence of any one character "." up to many characters ".+" resp. ".+?", delimited by the left edge of the character string "^", or by space character around the word "\s", or by the right edge of the string "$".

Note:
There is a difference between ".+" and ".+?" resp. "." and ".?".
".+" is a greedy pattern, ".+?" is a non-greedy pattern.
By default, pattern matching is greedy, which means that the matcher returns the longest match possible.
For example, applying the pattern "A.c" to "AbcAbcA" matches "AbcAbc" rather than the first shorter "Abc".
To do non-greedy matching, a question mark must be added to the quantifier.
For example, the pattern "A.
?c" will find the shortest match possible, that is the first "Abc".

In Mp3tag it looks like ...

$regexp('AbcAbcA','^(A.+c).*$','$1')

==> Result $1 = 'AbcAbc'

$regexp('AbcAbcA','^(A.+?c).*$','$1')

==> Result $1 = 'Abc'

Your example "word1 word2 word3 wordn" can be coded into regex language ...
"^.+?\s.+?\s.+?\s.+$".

In Mp3tag it looks like ...

$regexp('word1 word2 word3 word4 word5','^(.+?)\s(.+?)\s(.+?)\s(.+)$','$1 - $2 - $3 # $4')

==> Result $1 = 'word1'
==> Result $2 = 'word2'
==> Result $3 = 'word3'
==> Result $4 = 'word4 word5'
==> Result = 'word1 - word2 - word3 # word 4 word 5'

You can group parts of the expression by surrounding round brackets and refer to each group by a numbered placeholder $n.

Your example "Firehouse '86 - K. Tubby" looks like a two-parted string, delimited by the character sequence " - ", with the meaning of "ALBUM - PRODUCER" or "ALBUM - ARTIST".

In Mp3tag it can be written as ...

$regexp('Firehouse 1986 - King Tubby','^(.+?)\s-\s(.+?)$','"$2" is the producer of "$1"')

==> Result $1 = 'Firehouse 1986'
==> Result $2 = 'King Tubby'
==> Result = '"King Tubby" is the producer of "Firehouse 1986"'

Assumingly the character string "Firehouse 1986 - King Tubby" is stored in the tag-field COMMENT, and the first part "Firehouse 1986" should be stored into the tag-field ALBUM, and the second part "King Tubby" should be stored into the tag-field "ARTIST", leaving the tag-field COMMENT as is, then the process using Mp3tag actions can be as following ...

Action: Format value
Field: ALBUM
Formatstring: $regexp(%COMMENT%,'^(.+?)\s-\s.+?$','$1')
==> Result $1 = 'Firehouse 1986'

Action: Format value
Field: ARTIST
Formatstring: $regexp(%COMMENT%,'^.+?\s-\s(.+?)$','$1')
==> Result $1 = 'King Tubby'

DD.20120516.1050.CEST


#19

thanks ever so much DetlevD! your reply adds a lot of great information.

may take me a minute to digest it all but i'm very grateful!