Script for ripping genre, year & record label from beatport.com


#34

ok, like for this URL: http://api.beatport.com/catalog/tracks?v=1...&id=2108597

This seems to be a page for one track only.
Since the structure it pretty different to a release page, you would need to write a whole new script.
And you could tag only one track with each script run.

When you have tracks bought from beatport with a track id, aren't these tracks full tagged already?


#35

reading your second answer, i understand.
wav files have no metadata. you transform them into mp3 and want metadata for that.
well, since the track api is rather simple, it should be possible to write a script for it. but i need some time for that, maybe I'll do it this week.

Can you give me a list of what data you want from the api page in what tag field?

And are ther tracks which list more than one releases at their track id page. Like tracks which appear on a album and on a compilation? If so, how to deal with that?


#36

Hi again

I managed to do some good work on it, so I can moge a bit on...

I still would like to have the beatport track ID in the tracknumber but also the "catalog #" tag
If posible to recup the beatport id from the filename (first part as default by beatport).
I now first put the id in the "catalog #" tag and let the script read that tag.
Please not that I changed the & when having 2 artists (or more) in a semicolomn.
This is more appropriate because some softs like WMP wil then be able to classify this tracks at both artists..

It would be nice I could use this scipt to automatiacly fetch data for x number of tracks.
Now i need to to 1 at a time :frowning:

Very much tanks if you wanna look into this.
I'm very much sure people will apprciate this.

[Name]=beatport.com
[BasedOn]=http://api.beatport.com
[AlbumUrl]=http://api.beatport.com/catalog/tracks?v=1.0&format=xml&id=%s
[SearchBy]=%catalog #%

[ParserScriptAlbum]=...
outputto "tracks"
findline ""
findinline ">"
sayuntil "</"
findline ""
findinline ">"
say " ("
sayuntil "</"
say ")|"

outputto "year"
findline ""
findinline ""
sayuntil "</"

outputto "coverurl"
findline "width="60" height="60" ref="release""
moveline 1
findinline "image url=""
sayuntil "" "

#outputto "album""
#findline "<release exclusive="false""
#findinline ""
#sayuntil "</"

outputto "publisher"
findline "<label id"
findline ""
findinline ""
sayuntil "</"

outputto "genre"
findline "<genre id"
findline ""
findinline ""
sayuntil "</"

outputto "artist"
findline "<performer ref="Artist""
joinuntil ""
findinline ""
sayuntil "</"
moveline 1
unspace
if "<performer ref="Artist""
joinuntil ""
say "; "
findinline ""
sayuntil "</"
moveline 1
unspace
if "<performer ref="Artist""
set "albumartist", "Various Artists"
endif
endif
replace "|" "/"


#37

Thanks, its all a bit confusing at the min but I'll get it in all good time. I have done what you said and debuged the search by
release ID you posted in this post here and the returns it sends back are very detailed indeed!

BTW. I used your code:

[Name]=beatport.com
[BasedOn]=http://api.beatport.com
[AlbumUrl]=http://api.beatport.com/catalog/releases/detail?v=1.0&format=xml&id=
[SearchBy]=%discogs_release_id%

[ParserScriptAlbum]=...

The Release: 371080 is coming back with unfavoured results.

Its coming back with:
Artist: Red Carpet, Marcus Schossow
AlbumArtist: Artist: Red Carpet & Marcus Schossow
Album Artist: Artist: Red Carpet & Marcus Schossow
Title: Alright 2011 feat. Marcus Schossow ((Marcus Schossow Remix))
www
: http://api.beatport.com/catalog/releases/d...l&id=371080 for which I'd like the main URL

I would like to know how to change the Album Artist to match that of the Artist with a ", " I tried modifing the code:

moveline 1
unspace
if "<performer ref=\"Artist\""
joinuntil "</performer>"
say ", "
findinline "<name>"<PERFORMER performer ?

But this didn''t have the desired results. Its fine once the album goes over 3 artists then album artist becomes "VA" but having only two artists I want the " & " sign to become ", " and the title: Alright 2011 feat. Marcus Schossow ((Marcus Schossow Remix)) is not right. I'm not sure the reason for this.

Your script has developed so much and thanks for that. The export thing was a stroke for genious. :slight_smile:

Dunno really, but I have not really done much scripting it was all really simple stuff I have done so far but until I get a better understanding of it all then I'll just have to make do with pickin peoples brains on here!


#38

Here is the main URL:
http://www.beatport.com/release/alright-2011/371080
You get that by clicking on the preview button down left at the web sources dialog windows.

QUOTE (stevehero @ Aug 24 2011, 22:04) <{POST_SNAPBACK}>
I would like to know how to change the Album Artist to match that of the Artist with a ", " I tried modifing the code:
moveline 1
          unspace
          if "<performer ref=\"Artist\""
          joinuntil "</performer>"
          say ", "
          findinline "<name>"<PERFORMER performer ?

But this didn''t have the desired results. Its fine once the album goes over 3 artists then album artist becomes "VA" but having only two artists I want the " & " sign to become ", " and the title: Alright 2011 feat. Marcus Schossow ((Marcus Schossow Remix)) is not right. I'm not sure the reason for this.

I discovered the difference of artist and albumartist at many releases. I have solved this with an action group which I use after the web script i such cases. This also puts "artist 1, artist 2, artist 3" to "artist 1, artist 2 and artist 3":

Action 1: Format Value
Field: ARTIST
Formatstring: $regexp(%artist%,', ([^,]+)$',' & $1 ')

Action 2: Format Value
Field: MIXARTIST
Formatstring: $regexp(%mixartist%,', ([^,]+)$',' & $1 ')

But now as I dig deeper into that beatport script, I see it's easy to change inside the script:
change this:

<!--fonto:Courier New--><span style="font-family:Courier New"><!--/fonto-->outputto "Artist"
 sayregexp "(?<=<Artist>)[^<]+" <b>", "</b> "</track>"
 say "|"<!--fontc--></span><!--/fontc-->

into this:

<!--fonto:Courier New--><span style="font-family:Courier New"><!--/fonto-->outputto "Artist"
 sayregexp "(?<=<Artist>)[^<]+" <b>" & "</b> "</track>"
 say "|"<!--fontc--></span><!--/fontc-->

But that won't do the ..., ... & ... trick for three or more artists.
Here is a usefull threat on that freacky sayregxp command: /t/6993/1

For the ((Mixname)) thing: It seems that the beatport API page is somehow ill-formated. It has
(Marcus Schossow Remix)
where it normally should have
Marcus Schossow Remix

We can fix that with a regexpreplace command (the bold line is new):

<!--fonto:Courier New--><span style="font-family:Courier New"><!--/fonto-->outputto "tracks"
 findline "<name>"
 findinline ">"
 sayuntil "</"
 findline "<mixName>"

regexpreplace "(([^<]+))" "$1"

 findinline ">"<!--fontc--></span><!--/fontc-->

p.s.:
As you asked me for links at hints, I have forgotten to mention the very usefull freeware notepad++. It's like notedpad, but with plus plus more options and possibilities. It also refreshes the debug files when it is rewritten if you watch it with this tool:
http://notepad-plus-plus.org/
For this exists is an also very usefull language extension for the mp3tag web sources script language which highligts the comands of the script for a better overview. That helps to avoid typos, because you see they don't have the correct colour:
Web Sources Framework: Help needed

p.p.s:
I'm sorry. I didn't read your post carefully enough. I changed the , & artist albumartist thing exactly the other way around as you wanted it. For your desired solution you started right with replacing

say " & "

with

say ", "

at albumartist. And that is all what is necessary. You have also changed the next line (at least in the code you presented in your post). That would normally result into a Adjust Album Information window with all tag fields empty, because the line doesn't fit into the web sources syntax.

p.p.p.s:
Sorry, I also didn't understand your www problem. Here is the code for getting the main url when currentpreview is not available (as it is the case when you skip the [ParserScriptIndex]=... Part):

outputto "WWW"

gotoline 1
findline ""
findinline ""
say "http://www.beatport.com/release/"
sayuntil ""
say "/"
sayoutput "discogs_release_id"


#39

so i would advice you to use a different tag field for the beatport track ID, as this is something different as the catalog #.
But there seems to be no catalog # in the track-api-page. Only the beatport release id from where the track is taken from. You would have to do an additional run of a script for releases to to get the catalog #.

Yes. The tracknames are like trackid_title_name_mix_name.mp3, right? This will give you the frist numbers of the filename:

[SearchBy]=$regexp(%_filename%,^(\d+).+,$1)

The proper way to write multivalue tags in Mp3tag is to use \\ as a seperator. But this has some points you have to do right:
You have to write say "\\" to get \\.
And you have to save the files a second time after using the script to get the tag seperated.
see here: /t/9432/1
But if "; " works for you as a workaround, you can stick to this.

Here was a project to get this done. Don't know if it works. Tested it a while ago and didn't get it going. Produced a system crash after serveral trys. Now it says "project stopped" in the first post.
/t/6702/1

Your script generally works nice. Good work!

If you replace

outputto "tracks"

with

outputto "title"

you don't get that track number which will be always 1 for a script for one file.

p.s.:
and here is a working code to get the album name:

outputto "album"

findline "<release id="
joinuntil ""
findinline ""
sayuntil ""


#40

I fixed the problem myself in the mean time. This was my first bit of scripting and it was quite enjoyable seeing it work. :slight_smile: As much!

Thanks I see straight away its got a tab feature which is cool in itself and has style coding too. BTW what BB code editor is the best for posting to this forum. I'm using WYSIWYG BBCode Editor, http://wysiwygbbcode.codeplex.com/ pretty handy tool but it doesnt have spell check.

I will attached my lastest copy of the script so you can point out to me where I went wrong.

ADDITIONAL:
I see this within the script:
regexpreplace ">\s+<" "><" basically in scripting it replaces all white spaces inside >< (non greedy) to "BLANK"?

I've gone against the idea about tagging the 'exclusive to beatport.com' and instead what the description of the release there just like you have with the Discogs one.I've tried to code this below can't see what I am doing wrong? Unless it a multi line issue within the API?

# UNSYNCED LYRICS
outputto "unsyncedlyrics"
findline "<description>"
findinline "<description>"
sayuntil "</"

I have changed the 'coverurl' because I wanted to learn but am now curiuos to know can you add an if command to the ~ COVERURL then you search findline "width="60" height="60" ref="" instead?

# COVERURL
outputto "coverurl"
findline "width="500" height="500""
gotochar 1
findinline "url=\""
sayuntil "\" "

# COVERURL PROBLEM
outputto "coverurl"
findline "width=\"60\" height=\"60\" ref=\""
moveline 1
findinline "url=\""
sayuntil "\" "

_Beatport_stevehero__Release.src (5.75 KB)


#41

Thank u.

I added a new topic in support to add this functionality natively to MP3 tag.

I change the script based on your info, you can find it in the new topic i added
/t/12439/1

I did not changed the ";" to seperate artists because the \\ does not seem work in Windows Media Player. Only seperator thats works from what I know is the semicolomn ";"

Thanks again, I hope the people from MP3 tag will add this functionality


#42

I don't understand what you want to say with this example. The Spence & Hil Release of your link is an one-artist release. High Rankin is only the remixer. You don't want Remixers listed as albumartists, do you?

Use this code, to get two ALBUMARTIST with a Comma as seperator. The only line I changed is the one in red print. Btw: the last line belongs logically under the following # TRACK headline.

# ALBUMARTIST

outputto "albumartist"
findline "<performer ref="Artist""
joinuntil ""
findinline ""
sayuntil "</"
moveline 1
unspace
if "<performer ref="Artist""

joinuntil "</performer>"
say ", "
findinline "<name>"
sayuntil "</"
moveline 1
unspace
if "<performer ref=\"Artist\""
    set "albumartist", "VA"
# COMPILATION "1" IF "VA" outputto "compilation" say "1"
endif

endif
replace "|" "/"

no, only if there is nothing else as whitespaces

> bla bla <

will stay as it is

> <

will be replaced by

><
QUOTE (stevehero @ Aug 25 2011, 08:31) <{POST_SNAPBACK}>
I've tried to code this below can't see what I am doing wrong? Unless it a multi line issue within the API?
# UNSYNCED LYRICS
        outputto "unsyncedlyrics"
        findline "<description>"
        findinline "<description>"
        sayuntil "</"<!--QuoteEnd--></div><!--QuoteEEnd-->

the solution is again:

gotoline 1

the parser was at the frist descirption of the "Users Also Bought" section at.

yes:

COVERURL

outputto "coverurl"
findline "width="500" height="500"" 1 1
unspace
ifnot "<image url="

gotoline 1
findline "width=\"60\" height=\"60\" ref=\""
moveline 1

endif
findinline "url=""
sayuntil "" "

This makes use of an undocumented feature which is possible for some commands. findline "bla bla" 1 1. It is described here:
moveline to empty line fails

What are your exact questions about the two regualar expressions I used? I noticed the action group (which you won't use anyway) got displayed wrong in the forum, don't know why, I copy & pasted it from my Mp3tag Actions. I edited it in my post above and now it's correct.


#43

Sorry Pone, I havent got back to you (been busy) but thanks for all your help.

This worked how I wanted it to and now all the artist come in the format artist1, artist2, artist3, artist4 format. Thank you. Also Track headline is fixed and now reads.

# MIXARTIST    
    outputto "Mixartist"
    sayregexp "(?<=<Remixer>)[^<]+" ", " "</track>"
    say "|"
    moveline 1
    unspace
# TRACK
while "<track"

That's weird because thats one of the things I tried. Pity I didnt show you that. You probably dont believe me now!

Thanks for the coverurl fix. Works every time now.

Its okay the " ," trick worked. But for instance $regexp(%artist%,', ([^,]+) ,' & $1 ') How is this broken down?

SO, I think I'm actually finished moding this script with your great help. But I just need help for a couple of things. Its just to further get an understanding of scripting and its just the way I organise genres. I change "Progressive House" to "House Prog" and "Electro House" to "House Electro" etc. I have an action for this but I am banging my head against a wall trying to do this . I've tried the following codes:

1st attempt:

# GENRE
outputto "Genre"
findline "<genre"
joinuntil "</genre>"
findinline "<name>"
 if "Progressive House"
  say " House Prog"
 else
  say " "
  sayuntil "</"
  say "|"
 if "Electro House"
  say " House Electro"
 else
  say " "
  sayuntil "</"
  say "|" 
  endif

My logic behind this is output is to "genre" find where it says "<genre" and join until it says "</genre"
Find along the line till it finds ""
This is okay I understand that.
So this is where I've tried modifying it. I've used the same method as finding Original Mix for this one. But no luck.

2nd attempt:

# GENRE
outputto "Genre"
findline "<genre"
replace "Progressive House" "House Prog"
replace "Electro House" "House Electro"
findinline "<name>"
sayuntil "</"

I have looked at your script for "mixesdb.com" and tried to that same method here like you sample code below but no luck with that either. I wonder how you go about doing this, I've tried and cried until I'm blue in the face.

outputto "genre"
findline "id='catlinks'"
replace ">2 Step<" ">Genre:2 Step<"
findinline "Genre:" 1 1
sayuntil "<"

And I was wondering if its possible to get the total no of tracks and the description of the track in the "List of search results page"

EDIT
since the time of editing the url "http://www.beatport.com/release/its-our-future/74495" is not working properly. Its an early release so maybe its API'd differently. See "http://api.beatport.com/catalog/releases/detail?v=1.0&format=xml&id=74495"
I've tried looking at the debug info but it seems to be going over my head at this stage.
Thanks.


#44

First, what you quoted got displayed wrong in the forum, the correct formatstring I use is:
$regexp(%artist%,', ([^,]+)$',' & $1 ')

And analyzing it now, I see still a little mistake: the trailin space. From now on, I will use:
$regexp(%artist%,', ([^,]+)$',' & $1')

I break this down for you:

$regexp(%artist%,' ',' ')

A regexp function, that replaces something from the ARTIST tag-field. The parameters are in single quotes, because otherwis I could not use commas as litterals as I do in the second paramerter.

The second parameter, the regular expression:
', ([^,]+)$'

a comma and a space as litterals any character other than a comma repeated any number of times, but at least once the end of the line (= the end of the tag field)

the parentheses mark what is represented by $1 in the rhird parameter

in other words: everything from the last comma to the end of the tag-field, with the comma and the space following it excluded from the parentheses

The third parameter, the replace for the regular expression:
' & $1'

a space, an ampersand and a space as litterals what is captered by the parentheses in the second parameter

in other words: comma and the space which were excluded from the parentheses in the second parameter are repleaced with space-ampersand-space. The rest is left unchanged.

QUOTE (stevehero @ Sep 6 2011, 06:37) <{POST_SNAPBACK}>
SO, I think I'm actually finished moding this script with your great help. But I just need help for a couple of things. Its just to further get an understanding of scripting and its just the way I organise genres. I change "Progressive House" to "House Prog" and "Electro House" to "House Electro" etc. I have an action for this but I am banging my head against a wall trying to do this . I've tried the following codes:

1st attempt:

# GENRE
outputto "Genre"
findline "<genre"
joinuntil "</genre>"
findinline "<name>"
 if "Progressive House"
  say " House Prog"
 else
  say " "
  sayuntil "</"
  say "|"
 if "Electro House"
  say " House Electro"
 else
  say " "
  sayuntil "</"
  say "|" 
  endif<!--QuoteEnd--></div><!--QuoteEEnd-->

You forgot the endif which closes the first if section. And should leave away that else sections completly. Because as you planned it, there are several

say " "

sayuntil "</"
say "|"


repeated for one track when there are other genres the ones you are looking for. That doesn't work, because with every "|" the do...while loop for the tracks jumps to the next tag-field.
This here works:
     outputto "genre"
    findline "<genre"
    joinuntil "</genre>"
    findinline "<name>"
    if "Progressive House"
        say " House Prog"
        findinline "</"
    endif
    if "Electro House"
        say " House Electro"
        findinline "</"
    endif
    ifnot "name>"
        say " "
        sayuntil "</"
    endif
    say "|"

I don't understand why you want the empty spaces here before the genre names. But your decission.
And your second attempt is much easier:

QUOTE (stevehero @ Sep 6 2011, 06:37) <{POST_SNAPBACK}>
2nd attempt:
# GENRE
 outputto "Genre"
 findline "<genre"
 replace "Progressive House" "House Prog"
 replace "Electro House" "House Electro"
 findinline "<name>"
 sayuntil "</"<!--QuoteEnd--></div><!--QuoteEEnd-->

Almost correct. You just forgot the joinuntil "" line, which was there in the original script:

    outputto "genre"
    findline "<genre"
    joinuntil "</genre>"
    replace "Progressive House" "House Prog"
    replace "Electro House" "House Electro"
    findinline "<name>"
    sayuntil "</"
    say "|"

You can also try to work with regular expression replacements here to cover more genres:

regexpreplace "(.+?) House" "House $1"

That would not shorten "House Progressive" to "Hous Prog", but it would cover Acid House, Tech House, Vocal House, Deep House,... and possilbe genres which could come in the future like Rock House, Polka House, ... :wink:

QUOTE (stevehero @ Sep 6 2011, 06:37) <{POST_SNAPBACK}>
I have looked at your script for "mixesdb.com" and tried to that same method here like you sample code below but no luck with that either. I wonder how you go about doing this, I've tried and cried until I'm blue in the face.
outputto "genre"
 findline "id='catlinks'"
 replace ">2 Step<" ">Genre:2 Step<"
 findinline "Genre:" 1 1
 sayuntil "<"<!--QuoteEnd--></div><!--QuoteEEnd-->

I used replace ">2 Step<" ">Genre:2 Step<" there because at mixesdb.com, the genre is not marked as such but just another "category" besides others like like year, artist (dj), club, show. So I put the Genre: marker before the genre to be able to find them with the script. This is only possible because there is a closed group of 56 genres at mixesdb.com.

Have a look at my discogs script for total tracks. It was one of the most complicated things i have written in that script. It works in serveral steps, should be possible for beatport too:

    • Replace the element of the page code which marks a new track by a sepial marker.
    • Delete everything else (replace with nothing)
    • Replace the track begin markers with the roman number I
    • Do a long list of replacements which transforms the roman numbers into arabic numbers.

But then still, you are only able to write total tracks in a extra tag-field. You can't write it to TRACK in the form of 1/4, 2/4, 3/4, ... The only exception, I think, are mp4 files, where TOTALTRACKS is always an extra tag field.

I have seen no description of tracks at beatport. What do you mean?


#45

Well, I quickly adapted my script from discogs and it seems to be working. Add this at the end of the script:

#TOTALTRACKS    
outputto "TOTALTRACKS"
gotoline 1
joinuntil "<name>Users Also Bought</name>"
regexpreplace "</track>" "<<<Track>>>I<<<Track>>>"
regexpreplace ".*?(<<<Track>>>.*<<<Track>>>).*" "$1"
regexpreplace "<<<Track>>>[^I].*?<<<Track>>>" "<<<Track>>>"
replace "<<<Track>>>" ""
replace "IIIIIIIIII" "X"
replace "XXXXXXXXXX" "C"
replace "CI" "C0I"
regexpreplace "X$" "X0"
regexpreplace "C$" "C00"
replace "CCCCCCCCC" "9"
replace "CCCCCCCC" "8"
replace "CCCCCCC" "7"
replace "CCCCCC" "6"
replace "CCCCC" "5"
replace "CCCC" "4"
replace "CCC" "3"
replace "CC" "2"
replace "C" "1"
replace "XXXXXXXXX" "9"
replace "XXXXXXXX" "8"
replace "XXXXXXX" "7"
replace "XXXXXX" "6"
replace "XXXXX" "5"
replace "XXXX" "4"
replace "XXX" "3"
replace "XX" "2"
replace "X" "1"
replace "IIIIIIIII" "9"
replace "IIIIIIII" "8"
replace "IIIIIII" "7"
replace "IIIIII" "6"
replace "IIIII" "5"
replace "IIII" "4"
replace "III" "3"
replace "II" "2"
replace "I" "1"
sayrest

#46

Thanks for that great explaination pone. I've tried my own so can you see what you think. Its just a dummy action but I want to know how you would maybe go about optimising it if at all? I know a little about regexp thanks to the regexBuddy app.

Original title:
Time to, get down, Extended Mix or
Time to, get down, Original Mix
Need this result:
Time to - get down (Extended Mix) or
Time to - get down (Original Mix)

I've used the action:
Action type: Format value
Field: TITLE
Formatstring: $regexp(%title%,'^(.+?),\s(.+),\s(Original Mix|Extended Mix)$','$1 - $2 ($3)')

With regards the two "genre" pieces to the script they unfortunatly dont work for me with an error code.

The 1st option:

outputto "genre"
findline "<genre"
joinuntil "</genre>"
findinline "<name>"
    if "Progressive House"
        say " House Prog"
        findinline "</"
    endif
    if "Electro House"
        say " House Electro"
        findinline "</"
    endif
    ifnot "name>"
        say " "
        sayuntil "</"
    endif
    say "|"

Comes back with debug info:

Not sure what the error could be here?

And 2nd option (One I will probably use):

outputto "genre"
findline "<genre"
joinuntil "</genre>"
replace "Progressive House" "House Prog"
replace "Electro House" "House Electro"
findinline "<name>"
sayuntil "</"
say "|"

Comes back with debug info:

It seems that the replace is working fine to "House Electro" but then the error is generated so basiclly it happens within:
findinline ""
sayuntil "</"
say "|"

Please see the jpeg attached to the post to see want I mean.

But thank you for the year code. I was trying to add the following code below the one you gave to output the track no as follows: 1/12, 2/12 etc

# TRACK/TOTAL TRACKS
# PLACE AFTER TRACK & TOTALTRACKS
outputto "track"
say "/"
sayoutput "TOTALTRACKS"
say ""



#47
QUOTE (stevehero @ Sep 6 2011, 22:23) <{POST_SNAPBACK}>
.... I was trying to add the following code below the one you gave to output the total track no as follows: 1/12, 2/12 etc
# TRACK/TOTAL TRACKS
# PLACE AFTER TRACK & TOTALTRACKS
outputto "track"
say "/"
sayoutput "TOTALTRACKS"
say ""<!--QuoteEnd--></div><!--QuoteEEnd--> 

I've created an action shown below which I can quickly run afterwards along with my other actions. (saves time having to go near the autonumbering wizard as long as there is a TOTALTRACKS field available).

Name of action group: For&mat#TRACK %track%%totaltracks%

Action #1:
Action type: Format value
Field: TRACK
Formatstring: %track%/%totaltracks%

Action #2:
Action type: Replace with regular expression
Field: TRACK
Regular expression: (\d+)/(\d+)/(\d+)$
Replace matches with: $1/$2

[ ] case-sensitive comparison

Action #3:
Action type: Replace with regular expression
Field: TRACK
Regular expression: /+$
Replace matches with:

[ ] case-sensitive comparison

Action #1 Formats the TOTALTRACKS to the TRACK field in the format TRACK/TOTALTRACKS.
Action #2 Makes sure that the TRACK field follows that format for good by removing 02/10/10 if it exists leaving the correct value.
Action #3 If there is no total disks present then it removes any "/" which might be created from action #1.

BUT if you have any suggestions on how to improve this it would be great, I'm sure you will. Would still be nice if it could be implemented in the script beforehand. :stuck_out_tongue:

PS I'm getting slightly addicted to this script and scripting in general!!!


#48

#49

I have it within the "while loop" too. I've attached the script, I cant see the problem at all

I just wondered considering your discogs script had the info one.

No, maybe TRACK is one of those field where you cant output to?

No, just wondered if there was an all-in-one regexp to do it. But Ive added more to the action. This is if you have the TOTALTRACKS filed as "10" say it formats the TRACK field as follows "1/10" "2/10" etc and then if they are in that format with the TRACK field as "1/10" "2/10" etc and with the TOTALTRACKS field empty it puts in the "10" for example to TOTALTRACKS

Its a clever wee action because if you have an empty TRACK field it deletes the TOTALTRACKS obviously because there is not a TRACK field to begin with so it makes sence.

This action by no means takes over from the autonumbering wizard but is a nice wee tool to have.

Name of action group: For&mat#TRACK %track%%totaltracks%

Action #1:
Action type: Format value
Field: TRACK
Formatstring: %track%/%totaltracks%

Action #2:
Action type: Replace with regular expression
Field: TRACK
Regular expression: (\d+)/(\d+)/(\d+)$
Replace matches with: $1/$2

[ ] case-sensitive comparison

Action #3:
Action type: Replace with regular expression
Field: TRACK
Regular expression: /+$|^0+
Replace matches with:

[ ] case-sensitive comparison

Action #4:
Action type: Replace with regular expression
Field: TRACK
Regular expression: ^/\d+$
Replace matches with:

[ ] case-sensitive comparison

Action #5:
Action type: Format value
Field: TOTALTRACKS
Formatstring: %track%

Action #6:
Action type: Replace with regular expression
Field: TOTALTRACKS
Regular expression: ^\d+$
Replace matches with:

[ ] case-sensitive comparison

Action #7:
Action type: Replace with regular expression
Field: TOTALTRACKS
Regular expression: ^(\d+/)(\d+)$
Replace matches with: $2

[ ] case-sensitive comparison

EDIT
I've also noticed the coverurl code had strange effects on some albums even with your fix. for example on http://api.beatport.com/catalog/releases/d...ml&id=52765 I think the problem lies when it says (see bold writing) instead of true. So I have added it to the very end of the script and it seems to have done the trick to allow the script to work in them troubled releases, but it grabs the wrong cover from the "People Also Bought" section and none when the cover art is correct.

I added gotoline in line 2 of the command. But with no success (see below) Wonder why that is?

outputto "coverurl"
gotoline 1
findline "width="500" height="500"" 1 1
unspace
ifnot "<image url="
gotoline 1
findline "width=\"60\" height=\"60\" ref=\""
moveline 1
endif
findinline "url=\""
sayuntil "\" "

_Beatport_stevehero__Release.src (7.17 KB)


#50
QUOTE (stevehero @ Sep 10 2011, 06:14) <{POST_SNAPBACK}>
I have it within the "while loop" too. I've attached the script, I cant see the problem at all :frowning: It goes through the finding of the release etc , but when i get the page to chek everything the left bottom box has no tracks showing, genre has "error" in it and no artist shows :frowning:

Any ideas?


#51

I'm working on it ATM, your going to have to go back to the old one for the time being I'm afraid but I will post the script once I'm completely happy with it. It shouldn't be long. I just need to figure out how to fix the artwork issue and a couple of other things.

PS can you take my quote out of your reply as it fills this forum and hasn't much relevance to the Question. Cheers :slight_smile:


#52

About the Genre replacement problem:

I've found your mistake in the script you attached in the forum post. You have repeated the last three lines of the #genre section in the #trackname section which comes afterwards.

this is your code, the red lines are wrong:

# GENRE

debug "on" "C:\Users\Sir Seppone\AppData\Roaming\Mp3tag\data\sources\debug.txt"
outputto "genre"
findline "<genre"
joinuntil ""
replace "Progressive House" "House Prog"
replace "Electro House" "House Electro"
findinline ""
sayuntil "</"
say "|"

TRACK NAME

findinline ""
sayuntil "</"
say "|"<!--colorc--></span><!--/colorc--><!--fontc--></span><!--/fontc--><!--fonto:Courier New--><span style="font-family:Courier New"><!--/fonto-->
findline "<performer"<!--fontc--></span><!--/fontc-->

btw.: the debug file shows you in which line the error is happening. this showed pointed me directly to the wrong line. so it's good to use a text editor which shows the numbers of the line.


#53

About the Cover Art problem:

QUOTE (stevehero)
In the beatport script concerning the cover art. I want it to gotoline 8 where the 500px images are mostly always stored therefore I want to findinline "width="500" height="500"" and if it cant find it I want it to jump to line 7 where the 60px image of the release will always be. I've checked a lot of various release API's and they ALL hold these values with line 8 being either a 500px of the release or a different sized .jpg of the label but always line 7 is the 60px version of the release. Thats why I want it to default to line 7 if findinline 8 fails.

I have a feeling where I'm goin wrong is the ifnot line? But I'm not sure.

My attempt.

COVERURL

outputto "coverurl"
gotoline 8
findinline "width="500" height="500"" 1 1
ifnot "<image url="
gotoline 7
endif
findinline "url=\""
sayuntil "\" "

I'm still not 100% sure what the "1 1" after findinline does. I read the link you gave me but still not getting it.

Yes, ifnot is part of the problem. And you also deleted the unspace command. And you replaced findline with findinline. And you didn't escape the qutoationmarks. All these things lead to different results.

findline "text" 1 1
Finds the first next line which contains "text". If "text" can't be found in any of the next lines, the parser stops at the last line. Without the second 1 in the command, the script would stop and show if text can't be found.
After a findline command, the parser is always at the first character of a line.

findinline "text" 1 1
Finds the first next occurence of "text" in the line. If "text" can't be found in the line, the parser stops at the end of the line. Without the second 1 in the command, the script would stop and show if text can't be found.
After a findinline "text" command, the parser is at the first character which follows after "text" in the line.

unspace
This removes leading and trailing spaces of lines. And it sets the parser back to the first character of the line.

You can check the position of the parser after every line in the debug file. It is show line at "Line and position:" by this symbol: ^

This was all essential in my fix:

findline "width="500" height="500"" 1 1

unspace
ifnot "<image url="

The first line here looked for a line with width="500" height="500" in it.

If width="500" height="500" can't be found, the parser stops at the last line. Unspace doesn't change anything. And the ifnot command has a positive result (positive = the last line does not start with "<image url=" so the ifnot condition is positive, the lines until endif are executed).
If width="500" height="500" can be found, the parser stops at this line. Unspace removes the leading spaces. And the ifnot command has a negative result (negative = the line does start with "<image url=" so the ifnot condition is negative, the lines until endif are ignored).

The only thing I wonder: I don't know if my fix as I presented it in the forum worked at all. I forgot to escpape the parenthesis. The first line must be written as wollowing:
findline "width=</b>"500</b>" height=</b>"500</b>"" 1 1

So, for what you want to do now:

outputto "coverurl"

gotoline 8
findinline "width="500" height="500"" 1 1
movechar -24
ifnot "width="500" height="500""

gotoline 7

else

gotochar 1

endif
findinline "url=""
sayuntil "" "

After findinline "width="500" height="500"" 1 1 this script goes back 24 characters (the exact length of "width="500" height="500", this time without escaping the quotationmarks) and checks with ifnot, if the seached text has (not) be found. If it has not been found, it moves to line 7, if found it moves to the first character of the line (because otherwise, the following findinline "url="" would find nothing).

By the way:

ifnot "width=\"500\" height=\"500\""
 gotoline 7

else

 gotochar 1

endif

is exactly the same as: if "width=\"500\" height=\"500\"" gotochar 1 else gotoline 7 endif