Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GetMusicVideos(ArrayArtists,ArrayMBIDs,varMessage)
- {
- global varAUDIODBKEY, varDatabasefile, varCANCEL, varShowTrayTips, Sources, SourceAudioDB
- ArrayVideos := Object()
- ; for index, in ArrayArtists
- ; msgbox % index
- ; Get Video URLS from other Sources
- for source, in Sources
- {
- FileRead, xmlString, Files\%source%
- msgbox % xmlString
- Pos := 1
- Loop
- {
- Pos := RegExMatch(xmlString, "<mvdartist>([^<>]*)</mvdartist>", Out, Pos)
- Artist := Out1
- RegExMatch(xmlString, "<mvdtitle>([^<>]*)</mvdtitle>", Out, Pos)
- Title := Artist . " - " . Out1
- RegExMatch(xmlString, "<mvdurl>([^<>]*)</mvdurl>", Out, Pos)
- Url := Out1
- if (IsAnIndex(Artist,ArrayArtists))
- If (title <> "unknown")
- ArrayVideos[Artist,title] := Url
- Pos++
- } until Pos = 1
- }
- if (SourceAudioDB)
- {
- Count := 0
- for x in ArrayMBIDS
- Count++
- for varMBID, in ArrayMBIDS ;Get Video URLS for MBIDS from AudioDB
- {
- varCacheFile := "Cache\" varMBID ".txt"
- if not FileExist(varCacheFile)
- URLDownloadToFile, http://www.theaudiodb.com/api/v1/json/%varAUDIODBKEY%/mvid-mb.php?i=%varMBID%, %varCacheFile%
- fileread, jsonString, %varCacheFile%
- ifinstring, jsonstring, % "{""mvids"":null}"
- Continue
- Artist := ArrayMBIDs[varMBID]
- PosA := 1
- Loop
- {
- PosA := RegExMatch(jsonString, """strTrack"":""(.[^""]*)""", Out, PosA)
- Title := JavaEscapedToUnicode(Out1)
- RegExMatch(jsonString, """strMusicVid"":""(.[^""]*)""", Out, PosA)
- URL := cmdCleanYouTubeURL(Out1)
- if (URL = "ERROR")
- Title := ""
- if Title is not space
- {
- Title := Artist . " - " . Title
- ArrayVideos[artist,title] := Url
- }
- PosA++
- } until PosA = 1
- if varShowTrayTips
- TrayTip,, % "Adding music videos for:`n" ArrayMBIDS[varMBID]
- GuiControl, ,varProgress2, % A_Index / Count * 100
- if varCancel
- Return
- }
- }
- GuiControl, ,varProgress2, 100
- if (varShowTrayTips)
- TrayTip,, Finished Creating Music Video List for`n %varMessage%
- Gui, Confirm:Default
- Gui, Confirm:Add, ListView,w700 sort, Name|URL Code
- for artist, in ArrayVideos
- for title, in ArrayVideos[artist]
- LV_Add("", title, ArrayVideos[artist,title])
- LV_ModifyCol()
- Gui, Confirm:Add, Button, gDelete, Delete
- Gui, Confirm:Add, Button, gView, View
- Gui, Confirm:Add, Button, gEdit, Edit
- Gui, Confirm:Add, Button, gSubmit, Submit
- Gui, Adding:Hide
- Gui, Confirm:Show
- Goto EndFunction
- Delete:
- RowNumber := 0
- DeleteArray := []
- Loop
- {
- RowNumber := LV_GetNext(RowNumber)
- if not RowNumber
- Break
- DeleteArray[RowNumber] := "DEL"
- }
- for index, in DeleteArray
- LV_Delete(index-A_Index+1)
- Return
- View:
- RowNumber := 0
- Loop
- {
- RowNumber := LV_GetNext(RowNumber)
- if not RowNumber
- Break
- LV_GetText(Text, RowNumber,2)
- msgbox % text
- }
- Return
- Edit:
- RowNumber := 0
- Loop
- {
- RowNumber := LV_GetNext(RowNumber)
- if not RowNumber
- Break
- LV_GetText(Text, RowNumber,1)
- InputBox, text, Edit Video Name,,,,,, , , , %text%
- LV_Modify(RowNumber, "", text)
- }
- Return
- Submit:
- GuiControl, Disable, Submit
- GuiControl, Disable, Edit
- GuiControl, Disable, View
- GuiControl, Disable, Delete
- if (varShowTrayTips)
- TrayTip,, Adding Videos to databse for:`n %varMessage%
- Loop % LV_GetCount()
- {
- LV_GetText(title, A_Index, 1)
- LV_GetText(url, A_Index, 2)
- IniRead, Status, %varDatabaseFile%, DOWNLOAD LIST, %URL%, % "__________"
- Status := SubStr(Status,2,4)
- IniWrite, % " (" Status ") " . title, %varDatabaseFile%, DOWNLOAD LIST, %url%
- }
- Pause Off
- Return
- EndFunction:
- Pause On
- Gui, Confirm:Destroy
- Gui, Adding:Show
- Return
- }
- IsAnIndex(Str,Array) ;Returns True if Str is an index for Array
- {
- for index, in Array
- {
- if (Str = Index)
- Return TRUE
- }
- return FALSE
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement