SRL Archive - OSR Help

Downloading files through scar?


Xtensity

2010-02-24 13:59:02

Is there a way for me to download and save files in scar?


I'm trying to just make a script that will download multiple files, some contain specific extensions, and some with certain prefixes. I know how to get the URL of the file etc, but how exactly do I save an MP3 file or an MPG/AVI file from a site through scar

Reason I'm trying to get a script for this is so that I can download several videos with the same prexes without having to go to each link, telling it where to save etc.

Any tips

edit: I also want this so I can auto categorize the files based off certain words in the URLs in specific folders. This would negate much of the hassle of telling it where to save then making a series of folders to organize them.

mixster

2010-02-24 14:03:20

var  fileInt: Integer;
begin
fileInt := RewriteFile('C:\etc_etc\movie.avi', False);
if (fileInt = -1) then
begin
Writeln('-1 means it failed for whatever reason - unable to access it maybe or don''t have permission');
TerminateScript;
end;

if not WriteFileString(fileInt, 'string to write to the file, ie the returned GetPage stuff') then
Writeln('Failed to write to the file - don''t terminate here though as you still need to close the file');

CloseFile(fileInt);
end.

I believe it should compile, though you'll probably not want it in quite this form :)

Xtensity

2010-02-24 14:08:19

From: mixster
var  fileInt: Integer;
begin
fileInt := RewriteFile('C:\etc_etc\movie.avi', False);
if (fileInt = -1) then
begin
Writeln('-1 means it failed for whatever reason - unable to access it maybe or don''t have permission');
TerminateScript;
end;

if not WriteFileString(fileInt, 'string to write to the file, ie the returned GetPage stuff') then
Writeln('Failed to write to the file - don''t terminate here though as you still need to close the file');

CloseFile(fileInt);
end.

I believe it should compile, though you'll probably not want it in quite this form :)

Wait, uh, Where does the URL of the file go? Like the webpage link? GetPage only returns a string

Edit:still pretty confused, tried all the functions under file and internet functions and can't get any of them to work how I need lol.

mixster

2010-02-24 14:50:12

You would just need to replace 'string to write to the file, ie the returned GetPage stuff' with GetPage('http://blah.com/whatever.avi') I would think (the WriteFileString line). You probably also want to change which file it opens, by changing the 'C:\etc_etc\movie.avi' string for RewriteFile.

Xtensity

2010-02-24 15:42:36

Ok I got it working so far from what you've helped me with…. but how do I make it not write files that don't exist on the site, or how can I make it delete files that are to small? I couldn't find any function for deleting or removing a file after it writen.

mixster

2010-02-24 16:03:28

Scar doesn't have anything to delete a file in it already - you can empty it so it contains nothing, but that's about it (there is a way to delete files using some other stuff, but that's a bit confusing).

However, what you could do is store the string in a variable and if the string is too short, then you don't write it to a file.

senrath

2010-02-24 17:07:24

In order to delete a file, you have to enable API calls, and use part of the windows API to do so.