[UPD ES] Filmaffinity 4.0

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
antp
Site Admin
Posts: 9745
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: [UPD ES] Filmaffinity 4.0

Post by antp »

Microsoft is deprecating VBS, but you have time: it will be disabled by default (in new installs) in 2027 and removed only later :D

Next time I make an update to AMC I should try to add an option to use cURL, or at least a way to call it directly and discretely. I could do that easily by adding options to the Launch function (hide console, wait for app to close, ...)
Why do you need to create and execute a .ps1 rather than directly launching curl itself?
MrObama2022
Posts: 120
Joined: 2022-02-02 00:03:55

Re: [UPD ES] Filmaffinity 4.0

Post by MrObama2022 »

antp wrote: 2025-08-02 07:45:28 Why do you need to create and execute a .ps1 rather than directly launching curl itself?
Good point, I think ps1 file is useless and curl could be included in vbs, never tested. I got this solution by steps (first version was a nightmare). I don't know visualbasic or powershell, it's vibe coding ... you know, Gemini, Perplexity ...

If you want to switch to curl, you have to use a trick. The problem is that curl open the output file and then fill it with html so when you use FileExists inside your script you don't know really if file is already ready or not. That is why in my script I create it as .tmp and only after curl command is completer I rename it with the filename used in FileExists.

With Launch() this is how to do this:

Launch(curlPath, ' --silent -L -w "%output{' + InstallerPath + curlOutputTmp + '}" --output "' + InstallerPath + curlOutput + '" --url "' + address + '" ' + '-H "Accept: text/html, */*" [.......] -H "User-Agent: ' + curlUserAgent + '" 2>$null &');

With -w "%output{' + InstallerPath + curlOutputTmp + '}" the file curlOutputTmp is created only when curl command is completed. Then you can get the html that is in curlOutput

Code: Select all

    if (fileExists(InstallerPath + curlOutputTmp)) then
      DeleteFile(InstallerPath + curlOutputTmp);
      
    // please double check \" and fix, this is only a (working) test
    Launch(curlPath, ' --silent -L -w "%output{' + InstallerPath + curlOutputTmp + '}" --output "' + InstallerPath + curlOutput + '" --url "' + address + '" ' + '-H "Accept: text/html, */*" -H "Accept-Language: it" -H "DNT: 1" -H "Priority: u=0, i" -H "Sec-Ch-Ua: \"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", \"Google Chrome\";v=\"138\"" -H "Sec-Ch-Ua-Mobile: ?0" -H "Sec-Ch-Ua-Platform: \"Windows\"" -H "Sec-Fetch-Dest: Document" -H "Sec-Fetch-Mode: Navigate" -H "Sec-Fetch-Site: None" -H "Sec-Fetch-User: ?1" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: ' + curlUserAgent + '" 2>$null &');

    cnt := 0;
    // wait max 1 minute
    while ((not fileExists(InstallerPath + curlOutputTmp)) AND (cnt < 120)) Do
    begin
      cnt := cnt + 1;
      Sleep(500);
    end;  
    if (fileExists(InstallerPath + curlOutputTmp)) then
    begin
      DeleteFile(InstallerPath + curlOutputTmp);
      if (fileExists(InstallerPath + curlOutput)) then
      begin
        fileContent := TStringList.Create;      
        fileContent.LoadFromFile(InstallerPath + curlOutput);
        Result := fileContent.Text;
        fileContent.Free;
        DeleteFile(InstallerPath + curlOutput); 
      end;
    end;
Post Reply