Earliest release date from Discogs

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Re: Earliest release date from Discogs

Postby Hagar » Thu Apr 14, 2011 1:14 pm

Thanks, I'm having troubles with patience. I had to reboot mediamonkey to have it take effect. So I've got it down to 10 sec previews. Somehow, some songs aren't able to be created and yet some (few) are ghosted out and not played. And another is you still have to watch as a Aerosmith whole album got two different dates associated with it.

But this is a far sight better then no script at all to do this.
To bad the search in Media Monkey is associated with Amazon whom you think would be a tad bit better.

Still kudos to the guy who came up with this one. :D

Ya know playing around with this (and I think I reached my limit as I'm not getting any hit results) could this be scripted to use Wikipedia instead and maybe pull in original art work?
hmmmm, ah heck lets pull in the comments as well.

I was a long time fan and paid for Music-match before yahoo ruined it. And to do this same thing you had to plow through scores of hits. So glad to have discovered Media Monkey and I paid lifetime. Worth it!
Hagar
 
Posts: 47
Joined: Sat Dec 08, 2007 4:50 pm

Re: Earliest release date from Discogs

Postby Eyal » Mon Apr 25, 2011 1:58 pm

richiefinger wrote:Can someone please tell me how I can edit the code from this so I can get it to use "original year" instead of "year"


I did that change in the script for myself. The script is in \Program Files\MediaMonkey\Scripts\Auto\EarliestDateDock.vbs
Using Notepad (or any TEXT editor), modify lines 272 and 284 :

From:
Code: Select all
xdata.year =

To:
Code: Select all
xdata.originalyear =


I'm using the panel undocked, it's always visible, I can resize and move it. Looks like this:

Image

To better handle window resize, I've changed all Anchors alignment @ lines 56, 60, 73, 79 and 86 :
From:
Code: Select all
.Common.Anchors = 15

To:
Code: Select all
.Common.Anchors = 5



To disable automatic date update, so you need to expressly click on a radio button, change lines 245, 247, 251 and 253 :
From:
Code: Select all
.checked = True

To:
Code: Select all
.checked = False



Finally, to prevent the script from setting Cutom5 field with "Date Corrected" string, disable (or delete) lines 278 and 285.
___________________________________________

SO... this is the script with all above mods:
Code: Select all
'This script will display a dockable window that shows the searched release dates from discogs,
'will automatically select and save the earliest exact match to date only
'
'made by yhsiuqs        http://www.mediamonkey.com/forum/viewtopic.php?f=2&t=42411
'email to ubersquishy at gmail dot com

Public Const iMatchesPerSong = 7

Public APIKey
Public XMLdoc, XMLdoc2
Public SrchTxt, SrchType
Public aSongMatchLinks
'
' the first fields in the last Publicension is an integer showing the heirarchy of the release year
'
' 1 = earliest release year from all results, is an exact match
' 2 = earliest release year from all results, not an exact match
' 3 = earliest release year from exact matches
' 4 = earliest release year from non-exact matches
' 5 = later release, is an exact match
' 6 = later release, is not an exact match
'
Public aList
Public xTemp,xData
Public fMain,bStartStop,bApply,lvMain,cOptions,lProgress
Public oRelease
Public aTrackList
Public iArrayIndex1
Public iArrayIndex2
Public aReleaseLinks()
Public bRunFlag
Public fProgress
Public bChecked

Public Sep, Mnu, Pnl, LblAPI, Edt, LblCurrent, lMatches, lCurrent, iExact, iFuzzy
Public rButtons()

Sub OnStartup
   Dim x,i
   set i = SDB.IniFile
   Set UI = SDB.UI
   Set Pnl = UI.NewDockablePersistentPanel("DateFixer")
   if Pnl.IsNew then
       Pnl.DockedTo = 2
       Pnl.Common.Width = 250
   end if
   Pnl.Caption = "Date Fixer"
   Script.RegisterEvent Pnl, "OnClose", "PnlClose"
   redim rButtons(iMatchesPerSong)

   Set LblAPI = UI.NewLabel(Pnl)
   LblAPI.Autosize = false
   LblAPI.Caption = "Discogs API Key"
   LblAPI.Alignment = 2 'centered
   LblAPI.Common.SetRect 10, 10, Pnl.Common.Width-20, 15
   LblAPI.Common.Anchors = 5  'Left+Right                        'Eyal: changed from 15  '1+2+4+8

   Set Edt = UI.NewEdit(Pnl)
   Edt.Common.SetRect 10, 25, Pnl.Common.Width-20, 15
   Edt.Common.Anchors = 5  'Left+Right                        'Eyal: changed from 15  '1+2+4+8
   Script.RegisterEvent Edt, "OnChange", "EdtSave"
   if i.ValueExists("EarliestDateDock","APIKey") then
      Edt.Text = i.StringValue("EarliestDateDock","APIKey")
   else
      Edt.Text = "Key"
   end if

   Set lCurrent = UI.NewLabel(Pnl)
   lCurrent.Autosize = False
   lCurrent.Alignment = 2 'centered
   lCurrent.Caption = "Current Info"
   lCurrent.Common.SetRect 10, 50, Pnl.Common.Width-20, 20
   lCurrent.Common.Anchors = 5  'Left+Right                        'Eyal: changed from 15  '1+2+4+8

   Set LblCurrent = UI.NewLabel(Pnl)
   LblCurrent.Autosize = False
   LblCurrent.Alignment = 2 'centered
   LblCurrent.Common.SetRect 10, 70, Pnl.Common.Width-20, 20
   LblCurrent.Common.Anchors = 5  'Left+Right                        'Eyal: changed from 15  '1+2+4+8
   
   Set lMatches = UI.NewLabel(Pnl)
   lMatches.Autosize = False
   lMatches.Alignment = 2 'centered
   lMatches.Caption = "Search Results"
   lMatches.Common.SetRect 10, 100, Pnl.Common.Width-20, 20
   lMatches.Common.Anchors = 5  'Left+Right                        'Eyal: changed from 15  '1+2+4+8
   
   for x = 1 to imatchespersong
      set rbuttons(x-1) = UI.NewRadioButton(Pnl)
      rbuttons(x-1).Common.SetRect 10,120+(x-1)*20,Pnl.Common.Width-20, 20
      rbuttons(x-1).Caption = ""
      rbuttons(x-1).Checked = False
      rbuttons(x-1).Common.Visible = False
      rbuttons(x-1).Common.ControlName = cstr("r" & x)
      Script.RegisterEvent rbuttons(x-1).common, "OnClick", "EvalButtons"
   next
   
   ' Add menu item that shows panel after it is closed
   Set Sep = SDB.UI.AddMenuItemSep(SDB.UI.Menu_View,0,0)
   Set Mnu = SDB.UI.AddMenuItem(SDB.UI.Menu_View,0,0)
   Mnu.Caption = "Date Fixer"
   Mnu.Checked = Pnl.Common.Visible
   Script.RegisterEvent Mnu, "OnClick", "ShowPanel"
   Script.RegisterEvent SDB, "OnPlay", "SearchCurrent"
End Sub
 
Sub ShowPanel(Item)
   Pnl.Common.Visible = not Pnl.Common.Visible
   Mnu.Checked = Pnl.Common.Visible
End Sub
 
Sub PnlClose( Item)
   Mnu.Checked = false
End Sub

Sub SearchCurrent
   LookupYear
End Sub

Sub LookupYear()
    Dim u,v, w, x, y, z
   Set UI = SDB.UI
   Set XMLdoc = CreateObject("Microsoft.XMLDOM")
   XMLdoc.async = "false"
   Set XMLdoc2 = CreateObject("Microsoft.XMLDOM")
   XMLdoc2.async = "false"
   u = 0
   APIKey = Edt.Text
   Set xdata = SDB.Player.CurrentSong
   srchtxt = xdata.artistname & " - " & xdata.title
   iExact = ""
   iFuzzy = ""
   for x = 1 to imatchespersong
      rbuttons(x-1).Caption = ""
      rbuttons(x-1).Checked = False
      rbuttons(x-1).Common.Visible = False
   next
   if cint(xdata.year) > 0 then
      LblCurrent.Caption = srchtxt & ", " & xdata.year
   else
      LblCurrent.Caption = srchtxt & ", no date"
   end if
   if len(APIKey) > 5 then
      if XMLdoc.load("http://www.discogs.com/search?type=all&q=" & SrchTxt & "&f=xml&api_key=" & APIKey) then 'there is search results
         set asongmatchlinks = xmldoc.getElementsByTagName("uri")
         if asongmatchlinks.length >= imatchespersong then
            u = imatchespersong
         elseif asongmatchlinks.length > 0 then
            u = asongmatchlinks.length
         else
            u = 0
         end if
         if u > 0 then
            redim areleaselinks(u)
            redim atemp(u,4)
            for y = 0 to (u - 1) 'load release links into array
               areleaselinks(y) = mid(asongmatchlinks(y).childnodes(0).nodevalue, instr(asongmatchlinks(y).childnodes(0).nodevalue ,"/release/")+9)
            next
            for y = 0 to (u - 1)
               if XMLdoc2.load("http://www.discogs.com/release/" & areleaselinks(y) & "?f=xml&api_key=" & APIKey) then
                  if cint(XMLdoc2.selectSingleNode("/resp").attributes.item(2).value) > 5000 then 'maxumimum Discogs searches have been performed for today
                     LblCurrent.Caption = "You have reached the maximum allowable searches from Discogs.  Please try again in 24 hours."
                     exit sub
                  end if
                  set oRelease = XMLdoc2.selectSingleNode("/resp/release")
                  atemp(y,1) = oRelease.selectSingleNode("artists/artist/name").text 'artist
                  Set aTrackList = oRelease.selectNodes("tracklist/track")
                  soriginal = ucase(xdata.title)
                  for each z in aTrackList
                     slookup = ucase(z.selectsinglenode("title").text)
                     if slookup = soriginal then 'exact match
                        atemp(y,2) = z.selectsinglenode("title").text
                        exit for
                     elseif instr(1,slookup,soriginal) <> 0 or instr(1,soriginal,slookup) <> 0 then 'title is found in the song title
                        atemp(y,2) = z.selectsinglenode("title").text
                     end if
                  next
                  if atemp(y,2) <> vbnullstring then 'found a match
                     on error resume next
                     z = 0
                     z = oRelease.selectsinglenode("released").text
                     if z <> 0 then
                        atemp(y,3) = left(oRelease.selectsinglenode("released").text,4) 'release year
                     else
                        atemp(y,3) = vbnullstring
                     end if
                     on error goto 0
                     if instr(1,ucase(atemp(y,1)),ucase(xdata.artistname)) <> 0 or instr(1,ucase(xdata.artistname),ucase(atemp(y,1))) <> 0 then 'matched artist and title
                        atemp(y,0) = 5 'show it's an exact match
                     else
                        atemp(y,0) = 6 'the data is in question
                     end if
                     rbuttons(y).Common.Visible = True
                     if atemp(y,3) <> vbnullstring then
                        rbuttons(y).Caption = atemp(y,1) & " - " & atemp(y,2) & ", " & atemp(y,3)
                     else
                        rbuttons(y).Caption = atemp(y,1) & " - " & atemp(y,2) & ", no date"
                     end if
                  end if
               end if
            next
            z = (-1) 'set earliest compare index for exact matches
            v = (-1) 'set index for non exact matches
            for y = 0 to (u - 1)
               if atemp(y,3) <> vbnullstring and isnumeric(atemp(y,3)) then 'there is a year found
                  if atemp(y,0) = 5 then 'exact match
                     if z = (-1) then 'haven't found an earlier release year in exact matches
                        if len(xdata.year) > 1 then
                           if cint(atemp(y,3)) < cint(xdata.year) then 'it's earlier than the current date
                              atemp(y,0) = 3
                              z = y
                           end if
                        else 'no year currently
                           atemp(y,0) = 3
                           z = y
                        end if
                     elseif cint(atemp(y,3)) < cint(atemp(z,3)) then 'it's an earlier release date
                        atemp(y,0) = 3
                        atemp(z,0) = 5
                        z = y
                     end if
                  else 'non exact
                     if v = (-1) then 'haven't found an earlier release year in non exact matches
                        if len(xdata.year) > 1 then
                           if cint(atemp(y,3)) < cint(xdata.year) then 'it's earlier than the current date
                              atemp(y,0) = 4
                              v = y
                           end if
                        else
                           atemp(y,0) = 4
                           v = y
                        end if
                     else
                        if cint(atemp(y,3)) < cint(atemp(v,3)) then 'it's an earlier release date
                           atemp(y,0) = 4
                           atemp(v,0) = 6
                           v = y
                        end if
                     end if
                  end if
               end if
            next
            if z <> (-1) and v <> (-1) then 'both exact and non exact have dates
               if cint(atemp(z,3)) <= cint(atemp(v,3)) then 'exact match is earlier or same release year
                  pnl.common.childcontrol("r" & z+1).checked = False            'Eyal: changed for False
               else 'non exact is earliest
                  pnl.common.childcontrol("r" & v+1).checked = False            'Eyal: changed for False
               end if
            else
               if z <> (-1) then 'there is an exact match
                  pnl.common.childcontrol("r" & z+1).checked = False            'Eyal: changed for False
               elseif v <> (-1) then 'there is a non exact match, but not an exact match
                  pnl.common.childcontrol("r" & v+1).checked = False            'Eyal: changed for False
               else 'no matches
               
               end if
            end if
            EvalResults
         end if
      end if
   else
      LblCurrent.Caption = "Please enter a valid discogs API key."
   end if
End Sub

Sub EvalResults
   Dim x
   for x = 1 to imatchespersong
      if rbuttons(x-1).common.visible = true then
         if pnl.common.childcontrol("r" & x).checked = true then
            if right(rbuttons(x-1).caption,4) <> "date" then 'there is a date
               xdata.originalyear = cint(right(rbuttons(x-1).caption,4))                          'Eyal: changed for OriginalYear
            end if
            exit for
         end if
      end if
   next
   'xdata.custom5 = "Date Corrected"                                                                  'Eyal: disabled
   xdata.updateDB
End Sub

Sub EvalButtons(r)
   if right(r.caption,4) <> "date" then 'there is a date
      xdata.originalyear = cint(right(r.caption,4))           'Eyal: changed for OriginalYear
      'xdata.custom5 = "Date Corrected"                       'Eyal: disabled
      xdata.updateDB
   end if
End Sub

Sub EdtSave(e)
   dim i
   set i = SDB.IniFile
   i.StringValue("EarliestDateDock","APIKey") = e.Text
End Sub


Cheers!

Eyal :~)
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
Eyal
 
Posts: 3052
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Re: Earliest release date from Discogs

Postby caewen » Tue May 03, 2011 2:22 pm

i was wondering if anyone could give me a quick hand here. i am trying to mod the script to put a year into SDB.Player.CurrentSong.Year and into SDB.Player.CurrentSong.OriginalYear. if a date exists in SDB.Player.CurrentSong.Year, don't update that field. i don't know squat about vbs, so i am just guessing on how to do it, however, it isn't doing what i want. the changes i have made give me this error:

Error #9 - Microsoft VBScript runtime error
Subscript out of range: '[number: -1]'
File: "long ass line here", Line 290, Column: 5

i have changed the following 2 subs in the script
Code: Select all
Sub EvalResults
   Dim x
   for x = 1 to imatchespersong
      if rbuttons(x-1).common.visible = true then
         if pnl.common.childcontrol("r" & x).checked = true then
            if right(rbuttons(x-1).caption,4) <> "date" then 'there is a date
               xdata.originalyear = cint(right(rbuttons(x-1).caption,4))
            end if
            exit for
         end if
      end if
   next
'   xdata.custom5 = "Date Corrected"
   xdata.updateDB
End Sub

Sub EvalButtons(r)
   if right(r.caption,4) <> "date" then 'there is a date
   if cint(xdata.year) > 0 then
      xdata.originalyear = cint(right(r.caption,4))
   else
      xdata.originalyear = cint(right(r.caption,4))
      xdata.year = cint(right(r.caption,4))
   end if
'      xdata.custom5 = "Date Corrected"
      xdata.updateDB
   end if
End Sub


anyone able to tell me how to make this work to update only the originalyear if year already exists, or update both year and originalyear if it doesn't?

thanks a ton
john

edit: dunno why, but just changing the second sub and not the first one works the way i want it to. it will change the originalyear field always, and will change year if it doesn't already have data in it. changed the section in code brackets to show the new part if anyone else wants to use it.
caewen
 
Posts: 4
Joined: Tue May 03, 2011 2:07 pm

Re: Earliest release date from Discogs

Postby corncobia » Sun Sep 11, 2011 3:28 pm

I would like to give this script a try but am having trouble with the Discogs API code. I signed up at Discogs but they no long use codes. Any ideas?

Thanks...
corncobia
 

Re: Earliest release date from Discogs

Postby Eyal » Sun Sep 11, 2011 5:53 pm

corncobia wrote: am having trouble with the Discogs API code.

I think you need it anyway. You can find your API key in Discogs web site (need to be logged in):
--> My Discogs (menu at top right) -> Settings --> API Access (tab).

:~)
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
Eyal
 
Posts: 3052
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Re: Earliest release date from Discogs

Postby Trajan » Mon Sep 12, 2011 12:33 pm

Thanks, Eyal, that worked. BTW, I LOVE your skins. I am currently alternating between two of your Zekton skins, (Red and Black Currant). I like Dawn also but it is not available on MediaFire. I get a message that the file is "Invalid or Deleted." Anyway, VERY nice work!
Trajan
 
Posts: 23
Joined: Fri Mar 21, 2008 4:35 pm

Re: Earliest release date from Discogs

Postby Blutarsky » Mon Nov 07, 2011 11:26 am

Would be great if:
(A) Could use MusicBrainz Database: seems more accurate than discogs
(B) Allow update of multiple tracks at once (with preview)
(C) Fix the clipped content! :
Image
Blutarsky
 
Posts: 192
Joined: Wed Mar 03, 2010 12:53 pm

Re: Earliest release date from Discogs

Postby spikestorey » Tue Jan 24, 2012 1:06 pm

Will there be an update for api v2
spikestorey
 

Re: Earliest release date from Discogs

Postby Hagar » Fri Feb 10, 2012 2:24 pm

I take it that this a dead issue now. It won't or doesn't work anymore?

NOOOOoooooooo :o

What can one do now to have the earliest date show in the date?

And I'm not talking by looking up auto tag from the web, that does an album search and not the song.

Discog seems to work only if I type in the group and each song. This is a pain for best of CD's.
Hagar
 
Posts: 47
Joined: Sat Dec 08, 2007 4:50 pm

Re: Earliest release date from Discogs

Postby Hagar » Tue Feb 14, 2012 1:24 am

Anyone, Buller,Buller?
Hagar
 
Posts: 47
Joined: Sat Dec 08, 2007 4:50 pm

Re: Earliest release date from Discogs

Postby Hagar » Sat Feb 25, 2012 12:09 am

Well then does anyone know if another script will do this?

anyone....?
Hagar
 
Posts: 47
Joined: Sat Dec 08, 2007 4:50 pm

Re: Earliest release date from Discogs

Postby Hagar » Wed Mar 07, 2012 6:46 pm

All right, is there another way to do this? Discogs perhaps.

Oh why oh why when the other way was working so well. :(
Hagar
 
Posts: 47
Joined: Sat Dec 08, 2007 4:50 pm

Re: Earliest release date from Discogs

Postby Guest » Fri Apr 06, 2012 10:09 am

Apparently Discogs made a big API change on 1/15/12 and e-mailed existing users new keys,
but I can't find any clear directions for new users to obtain one.

Looks like this script is d-e-d. |-(

-G
Guest
 

Re: Earliest release date from Discogs

Postby Hagar » Fri Apr 06, 2012 3:09 pm

I think got the new key or actually you don't need a key I think. This script just doesn't work with the new system. Wish I knew how to make it work or someone would say what works.
Discogs perhaps? :o

Hoping someone smarter then I takes up the challenge. :D

Dave
Hagar
 
Posts: 47
Joined: Sat Dec 08, 2007 4:50 pm

Re: Earliest release date from Discogs

Postby yhsiuqs » Fri Apr 27, 2012 11:03 am

Hey folks!

Sorry for not monitoring this thread anymore...it looks like the site stopped notifying me of new posts a while back. I also stopped using this script a couple of computer upgrades ago, forgetting that it was even there.

I will see about updating the script to handle the new stuff over at Discogs (and make it more user-friendly), but I can't guarantee anything. If you know anything about scripting, feel free to take the script and modify it however you feel fit...hopefully we will one day have an integrated solution that is both user-friendly AND bug-free!

T
yhsiuqs
 
Posts: 6
Joined: Tue Sep 01, 2009 9:43 pm

PreviousNext

Return to Need Help with Addons?

Who is online

Users browsing this forum: Exabot [Bot] and 9 guests