Problem with WebSearch Songlist

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderators: Gurus, Addon Administrators

crap_inhuman
Posts: 833
Joined: Sat Jan 26, 2013 6:00 am
Location: Friedberg / Hessen / Germany
Contact:

Problem with WebSearch Songlist

Post by crap_inhuman »

If i start auto-tag from web, all selected tracks are in this object: SDB.Tools.WebSearch.NewTracks.Item(i).Title

If i try to tag an album with multiple songs having the same songname, MM exchange the Discnumber and Trackorder for the 2 songs with same songname.

First time i fill the NewTracks objects with songname, DiscNumber and TrackOrder and call the subroutine ShowResult(ResultID), the order of the tracks are okay.

If i call the subroutine again without changing anything, the Disc and Track for the 2 songs are exchanged.

This is the trackorder after starting:
Title DiscNumber - Tracknumber

I Was Doing Allright 1-01
I Want More 1-02
You've Changed 1-03
Society Red 1-04
For Regulars Only (Alt Take) 1-05
It's You Or No One 1-06
For Regulars Only 1-07
Landslide 1-08
Modal Mood 1-09
Clear The Dex 1-10
Boy Saxophonist (Monologue By Dexter Gordon) 1-11
Soul Sister 2-01
Smile 2-02
Ernie's Tune 2-03
I Want More 2-04
The End Of A Love Affair 2-05
Serenade In Blue 2-06
You Said It 2-07
Love Locked Out 2-08
Blue Gardenia 2-09
Second Balcony Jump 2-10
Six Bits Jones 2-11
Lady Be Good 2-12
On Be Bop 2-13
Three O'ClocK In The Morning 3-01
Second Balcony Jump 3-02
Where Are You? 3-03
Cheese Cake 3-04
I Guess I'll Hang My Tears Out To Dry 3-05
Love For Sale 3-06
McSplivens 3-07
The Backbone 3-08
Soy Califa 3-09
Until The Real Thing Comes Along 3-10
You Stepped Out Of A Dream 3-11
Don't Explain 3-12
Our Love Is Here To Stay 4-01
Broadway 4-02
Stairway To The Stars 4-03
A Night In Tunisia 4-04
Willow Weep For Me 4-05
Scrapple From The Apple 4-06
Coppin' The Haven 4-07
Tanya 4-08
It All Began... 4-09
Kong Neptune 5-01
Darn That Dream 5-02
Hanky Panky 5-03
Devilette 5-04
Clubhouse 5-05
Jodi 5-06
I'm A Fool To Want You 5-07
Lady Iris B 5-08
Le Coiffeur 6-01
Manha De Carnival 6-02
Flick Of A Trick 6-03
Everybody's Somebody's Fool 6-04
Very Saxily Yours 6-05
Shiny Stockings 6-06
Who Can I Turn To 6-07
Heartaches 6-08
Dexter On Bird (Monologue By Dexter Gordon) 6-09
This is the trackorder after calling the subroutine the second time:
I Was Doing Allright 1-01
I Want More 1-02
You've Changed 1-03
Society Red 1-04
For Regulars Only (Alt Take) 1-05
It's You Or No One 1-06
For Regulars Only 1-07
Landslide 1-08
Modal Mood 1-09
Clear The Dex 1-10
Boy Saxophonist (Monologue By Dexter Gordon) 1-11
Soul Sister 2-01
Smile 2-02
Ernie's Tune 2-03
I Want More 2-04
The End Of A Love Affair 2-05
Serenade In Blue 2-06
You Said It 2-07
Love Locked Out 2-08
Blue Gardenia 2-09
Second Balcony Jump 3-02
Six Bits Jones 2-11
Lady Be Good 2-12
On Be Bop 2-13
Three O'ClocK In The Morning 3-01
Second Balcony Jump 2-10
Where Are You? 3-03
Cheese Cake 3-04
I Guess I'll Hang My Tears Out To Dry 3-05
Love For Sale 3-06
McSplivens 3-07
The Backbone 3-08
Soy Califa 3-09
Until The Real Thing Comes Along 3-10
You Stepped Out Of A Dream 3-11
Don't Explain 3-12
Our Love Is Here To Stay 4-01
Broadway 4-02
Stairway To The Stars 4-03
A Night In Tunisia 4-04
Willow Weep For Me 4-05
Scrapple From The Apple 4-06
Coppin' The Haven 4-07
Tanya 4-08
It All Began... 4-09
Kong Neptune 5-01
Darn That Dream 5-02
Hanky Panky 5-03
Devilette 5-04
Clubhouse 5-05
Jodi 5-06
I'm A Fool To Want You 5-07
Lady Iris B 5-08
Le Coiffeur 6-01
Manha De Carnival 6-02
Flick Of A Trick 6-03
Everybody's Somebody's Fool 6-04
Very Saxily Yours 6-05
Shiny Stockings 6-06
Who Can I Turn To 6-07
Heartaches 6-08
Dexter On Bird (Monologue By Dexter Gordon) 6-09
With this code lines i tested and reproduce it:

Code: Select all

Option Explicit
'
'
Const VersionStr = "Test"


' WebBrowser is visible browser object with display of discogs album info
Dim WebBrowser

' decoded json object representing currently selected release
Dim CurrentRelease, QueryPage

' counter
Dim counter
counter = 1

' Easier access of SDB.UI
Dim UI
Set UI = SDB.UI

' MediaMonkey calls this method whenever a search is started using this script
Sub StartSearchType(Panel, SearchTerm, SearchArtist, SearchAlbum, SearchType)

	Dim Results, ResultsReleaseID
	WriteLogInit
	WriteLog " "

	' This is a web browser that we use to present results to the user
	Set WebBrowser = UI.NewActiveX(Panel, "Shell.Explorer")
	WebBrowser.Common.Align = 5
	WebBrowser.Common.ControlName = "WebBrowser"
	WebBrowser.Common.Top = 0
	WebBrowser.Common.Left = 0
	SDB.Objects("WebBrowser") = WebBrowser
	WebBrowser.Interf.Visible = true
	WebBrowser.Common.BringToFront

	WriteLog "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"

	Set Results = SDB.NewStringList
	Set ResultsReleaseID = SDB.NewStringList

	Results.Add SearchTerm
	ResultsReleaseID.Add "1"

	SDB.Tools.WebSearch.SetSearchResults Results
	SDB.Tools.WebSearch.ResultIndex = 0


End Sub




' ShowResult is called every time the search result is changed from the drop
' down at the top of the window
Sub ShowResult(ResultID)

	SDB.Tools.WebSearch.ClearTracksData

	Dim SelectedTracks, i
	Set SelectedTracks = SDB.NewStringList

	WriteLog "Title - DiscNumber - Tracknumber"
	If counter = 2 Then
		WriteLog "After choosing the SearchResult from the drop-down-list the tracks with the name 'Second Balcony Jump' change the DiscNumber and TrackOrder"
		WriteLog "Disc and Track: 2-10 and 3-02"
	End If
	If counter = 1 Then
		WriteLog "This is the first start of the sub ShowResult. The sort of the tracks are correct"
		counter = 2
	End If
	WriteLog " "

	For i = 0 To SDB.Tools.WebSearch.NewTracks.Count - 1
		SelectedTracks.Add SDB.Tools.WebSearch.NewTracks.Item(i).Title
		WriteLog SDB.Tools.WebSearch.NewTracks.Item(i).Title & " " & SDB.Tools.WebSearch.NewTracks.Item(i).DiscNumberStr & "-" & SDB.Tools.WebSearch.NewTracks.Item(i).TrackOrderStr
	Next

	
	SDB.Tools.WebSearch.SmartUpdateTracks SelectedTracks
	SDB.Tools.WebSearch.RefreshViews   ' Tell MM that we have made some changes

	WriteLog " "	


End Sub


' This does the final clean up, so that our script doesn't leave any unwanted traces
Sub FinishSearch(Panel)

	If isObject(WebBrowser) Then
		WebBrowser.Common.DestroyControl      ' Destroy the external control
		Set WebBrowser = Nothing              ' Release global variable
		SDB.Objects("WebBrowser") = Nothing
	End If

	Script.UnregisterAllEvents

End Sub


Sub WriteLogInit

	Dim logdatei
	logdatei = SDB.ScriptsPath & "Discogs_Script.log"
	If SDB.Tools.FileSystem.FileExists(logdatei) = True Then
		SDB.Tools.FileSystem.DeleteFile(logdatei)
	End If
	WriteLog "Start DiscogsTagger " & VersionStr

End Sub


Sub WriteLog(Text)

	Dim filesys, filetxt, logdatei, tmpText
	'Const ForReading = 1, ForWriting = 2, ForAppending = 8
	logdatei = SDB.ScriptsPath & "Discogs_Script.log"
	Set filesys = CreateObject("Scripting.FileSystemObject")
	Set filetxt = filesys.OpenTextFile(logdatei, 8, True)
	tmpText = Time & Chr(9) & SDB.ToAscii(Text)
	filetxt.WriteLine(tmpText)
	filetxt.Close

End Sub

Reported by an user of the Discogs Tagger https://www.mediamonkey.com/forum/viewt ... 26#p471426
Metal up your ass !
-----------------------------------------------
I added my first 2 videos on youtube. The language is german.

Discogs Autorisierung: https://www.youtube.com/watch?v=oryxKKtnEnc
Discogs Tagger Bedienung: https://www.youtube.com/watch?v=85Wk-5rd-W0