home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
AACD
/
Online
/
NapSearch
/
NapSearch.Amirx
next >
Wrap
Text File
|
2000-08-13
|
7KB
|
268 lines
/* Napster search script for Amirc V1.0 © Purp|e 2000 :) */
/* C O N F I G A R E A */
AmsterPath = "DH0:Internet/Amster/Amster"
AmsterPort = "AMSTER.1"
MaxHits = 4
/* E N D C O N F I G A R E A */
Options results
if exists(AmsterPath) = 0 then do
techo("Amster Not Found: "Amsterpath)
call endprog
end
IRCPort = address()
parse arg SMode" "SearchString
NL='0a'x;ES= d2c(27);Bold = d2c(2);TC = 5
NotRun = "N"
DebugIt = "N"
If DebugIt = "Y" then do
techo("Port: "IRCPort)
techo("Mode: "smode)
techo("String: "searchstring)
End
If upper(SMode) = "FIND" then call FindIt
If upper(smode) = "GET" then call GetIt
If Upper(Smode) = "HIDE" then do
Ports = ShowList("P")
if pos(amsterport,ports) = 0 then do
techo("Error: Amster not running!")
call endprog
end
address(AMsterPort)
"HIDE"
End
If Upper(Smode) = "SHOW" then do
Ports = ShowList("P")
if pos(amsterport,ports) = 0 then do
techo("Error: Amster not running!")
call endprog
end
address(AMsterPort)
"SHOW"
End
If Upper(Smode) = "RUN" then do
Ports = ShowList("P")
if pos(amsterport,ports) ~=0 then do
techo("Error: Amster already running!")
call endprog
end
address command "Run >nil: "Amsterpath
call time(R)
do until pos(amsterport,ports) ~=0|Time(E) >20.00
Ports = ShowList("P")
delay(30)
End
if pos(amsterport,ports) = 0 then do
techo("Error! Amster Failed to load!")
call endprog
end
address(AMsterPort)
"CONNECT"
call endprog
End
If Upper(Smode) = "QUIT" then do
Ports = ShowList("P")
if pos(amsterport,ports) = 0 then do
techo("Error: Amster not running!")
call endprog
end
address(AMsterPort)
"SHOW"
"QUIT"
End
If Upper(Smode) = "QUIT" then do
Call HelpIt
End
If upper(smode) = "INSTALL" then DO
"say /alias /NapFind /rx NapSearch.amirx Find %p"
"say /alias /NapGet /rx NapSearch.amirx Get %p"
"say /alias /NapHide /rx NapSearch.amirx Hide"
"say /alias /NapShow /rx NapSearch.amirx Show"
"say /alias /NapRun /rx NapSearch.amirx Run"
"say /alias /NapQuit /rx NapSearch.amirx Quit"
"say /alias /NapHelp /rx NapSearch.amirx Help"
techo("Please Save your settings now!")
end
If upper(smode) = "HELP"|upper(smode) = "?"|upper(smode) = "" then DO
Call HelpIt
End
Call EndProg
Exit
FindIt:
techo("Searching for "bold""Searchstring""Bold" on Napster, Hits = "bold""maxhits)
Ports = ShowList("P")
if pos(amsterport,ports) = 0 then do
if debugit = "Y" then techo("Port not found, starting Amster...")
address command "Run >nil: "AmsterPath
NotRun = "Y"
end
Ports = ShowList("P")
call time(R)
do until pos(amsterport,ports) ~=0|Time(E) >20.00
Ports = ShowList("P")
if debugit = "Y" then techo("Waiting for port...")
delay(30)
End
if pos(amsterport,ports) = 0 then do
techo("Error! Amster Failed to load!")
call endprog
end
if debugit = "Y" then techo("Port ready!")
address(AmsterPort)
If NotRun = "Y" then "Hide"
"ISONLINE"
ison = RC
address(IRCPort)
if debugit = "Y" then techo("Ison: "ison)
address(AMsterPort)
if ison = 0 then do
"CONNECT"
checkconnect = RC
address(IRCPort)
if debugit = "Y" then techo("Check: "CheckConnect)
if checkconnect ~= 0 then do
techo("Error connecting to server!")
call endprog
end
end
address(AmsterPort)
call time(R)
do until ison2 = 1|Time(E) >60.00
address(AMsterPort)
"ISONLINE"
ison2 = rc
address(IRCPort)
if debugit = "Y" then techo("Waiting for online state...")
delay(30)
end
techo("Connected and Searching, Please Wait...")
address(AmsterPort)
'SEARCH TITLE = "'searchString'" STEM = SG'
do until res1 = 2
"SEARCHSTATE"
res1 = RC
if res1 = 0 then do
address(IRCPort)
techo("no list")
leave
end
delay(60)
end
address(IRCPort)
techo("Search Complete!")
if SG.COUNT < Maxhits then MaxHits = SG.COUNT
if debugit = "Y" then techo(Maxhits)
if SG.COUNT > 1 then do
techo("Displaying "Maxhits" of "SG.COUNT" Total Matches:")
do i = 0 to MaxHits-1
ConSpeed = GetConSpeed(SG.0.Link)
SongInfo = bold""i+1"."bold" "substr(SG.i.title,LastPos("\",SG.i.title)+1)", "SG.i.Size" bytes, "Bold""ConSpeed
techo(SongInfo)
setclip(NapSearchFind.i,SongInfo)
End
End
if SG.COUNT = 1 then do
techo("Displaying 1 of 1 Total Matches:")
ConSpeed = GetConSpeed(SG.0.Link)
SongInfo = bold""i+1"."bold" "substr(SG.0.title,LastPos("\",SG.0.title)+1)", "SG.0.Size" bytes, "Bold""ConSpeed
techo(SongInfo)
setclip(NapSearchFind.0,SongInfo)
End
if SG.COUNT = 0 then do
techo("No Matches Found.")
End
SetClip(NapSearchFind,MaxHits)
Return 0
GetIt:
Ports = ShowList("P")
if pos(amsterport,ports) = 0 then do
techo("Error: Amster not running!")
call endprog
end
Matches = Getclip(NapSearchFind)
address(IRCPort)
if debugit = "Y" then techo(Matches)
if searchstring > matches then DO
techo("Requested song number out of search result range, try again.")
call endprog
end
address(AmsterPort)
"ISONLINE"
ison = RC
address(IRCPort)
if ison = 0 then do
techo("Error: Amster went offline, try another search.")
call endprog
end
address(AmsterPort)
"SEARCHSTATE"
state = rc
address(IRCPort)
if State = 0 then do
techo("No Search Results Found. Do a search first!")
call endprog
end
if state = 1 then do
techo("Search already in progress, wait for results!")
call endprog
end
address(AmsterPort)
'DOWNLOAD 'searchstring-1
res1 = RC
address(IRCPort)
if debugit = "Y" then techo(res1)
SST = searchstring-1
techo("Downloading "getclip(NapSearchFind.sst))
Return 0
Endprog:
if debugit = "Y" then techo("Done.")
exit
Techo:
parse arg EchoString
"ECHO P="d2c(27)"b«NapSearch» C="TC" "EchoString
say EchoString
Return 0
GetConSpeed:
Speed = Arg(1)
If Speed = 0 then TheSpeed = "Unknown"
If Speed = 1 then TheSpeed = "14.4K"
If Speed = 2 then TheSpeed = "28.8K"
If Speed = 3 then TheSpeed = "33.6K"
If Speed = 4 then TheSpeed = "56K"
If Speed = 5 then TheSpeed = "ISDN 64K"
If Speed = 6 then TheSpeed = "ISDN 128K"
If Speed = 7 then TheSpeed = "Cable"
If Speed = 8 then TheSpeed = "DSL"
If Speed = 9 then TheSpeed = "T1"
If Speed = 10 then TheSpeed = "T3+"
Return TheSpeed
HelpIt:
techo("Usage:")
techo(" /RX NapSearch Install - Install Aliases (Save Config after!)")
techo(" /NapFind <Search String> - Search for a song")
techo(" /NapGet <Song Number> - Download Song found by /NapFind")
techo(" /NapHide Hide Amster")
techo(" /NapShow Show Amster")
techo(" /NapRun Run Amster and go online")
techo(" /NapQuit Quit Amster")
techo("End Usage.")
Return 0