Trying to make an Tapas unlocker

Ask questions and have them answered!
Post Reply
neroes
Posts: 21
Joined: Mon Apr 14, 2025 9:18 pm

Trying to make an Tapas unlocker

Post by neroes » Mon Jun 09, 2025 7:45 pm

hi I'm trying to make a small program that wakes up every 24 hours,
redeem all the WUF (free episodes every 3, 24 and 72 hours),
but i'm having trouble with the login, could you help @Squidy?

here is what i have so far in login, i'm using Playwright
and i do get a token back, but i'm not logged into the site just by using this token, also i also get a token if my login is invalid

Code: Select all

public static async Task LoginAsync(IPage page, IBrowserContext context, Credentials credentials)
{
    Console.WriteLine("Logging in...");

    // Check if the session cookie already exists  
    var cookies = await context.CookiesAsync();
    var sessionCookie = cookies.FirstOrDefault(cookie => cookie.Name == "JSESSIONID");

    if (sessionCookie != null)
    {
        // Validate the session token
        if (await IsSessionValidAsync(context))
        {
            Console.WriteLine("Already logged in. Session is valid.");
            return;
        }
        else
        {
            Console.WriteLine("Session is invalid. Proceeding with login...");
        }
    }

    // Prepare login data  
    var domain = "tapas.io";
    var endpoint = $"https://{domain}/account/authenticate";
    var postData = new Dictionary<string, string>
    {
        { "from", $"https://{domain}/" },
        { "email", credentials.Email }, // Replace with your email  
        { "password", credentials.Password }, // Replace with your password  
        { "offsetTime", "0" }
    };

    // Send POST request for authentication  
    var response = await page.APIRequest.PostAsync(endpoint, new()
    {
        DataObject = postData
    });

    // Check if the response contains the session cookie  
    var responseCookies = await context.CookiesAsync();
    sessionCookie = responseCookies.FirstOrDefault(cookie => cookie.Name == "JSESSIONID");
    if (sessionCookie is null)
    {
        Console.WriteLine("Login failed. Unable to retrieve session cookie.");
        throw new Exception("Login failed.");
    }

    // Set cookies globally  
    await context.AddCookiesAsync(responseCookies.Select(ConvertPlaywriteToNormalCookie));
    Console.WriteLine("Login successful. Session cookie set.");
}

User avatar
Squidy
Site Admin
Posts: 1508
Joined: Fri Mar 10, 2017 9:28 pm
Contact:

Re: Trying to make an Tapas unlocker

Post by Squidy » Tue Jun 10, 2025 12:46 am

I don't have experience with Playwright, but I think the issue is that DataObject is serialized to JSON, and that's not what the login endpoint expects. You want to send it as form data instead.

e.g.

Code: Select all

var formData = context.APIRequest.CreateFormData();
formData.Set(..., ...);
var response = await page.APIRequest.PostAsync(endpoint, new() {
    Form = postData
});
See the second example here.

Hope this helps!
I'm the admin and developer of HDoujin Downloader.

neroes
Posts: 21
Joined: Mon Apr 14, 2025 9:18 pm

Re: Trying to make an Tapas unlocker

Post by neroes » Tue Jun 10, 2025 5:25 pm

yields the same result...
i'm quite confused by the fact i get tokens back just like i see in
https://github.com/HDoujinDownloader/HD ... /Tapas.lua
but it also returns a token if the login is invalid
are we sure your login method is fully functional?
it also sometimes require a captha, do you handle that somehow?

neroes
Posts: 21
Joined: Mon Apr 14, 2025 9:18 pm

Re: Trying to make an Tapas unlocker

Post by neroes » Sun Jun 22, 2025 2:35 pm

so looked into it further, it seems that it is correct but the way we check login is incorrect as it will send an cookie that expired in 1970 if the login is wrong or missing captcha
btw. how do you handle captchas?

neroes
Posts: 21
Joined: Mon Apr 14, 2025 9:18 pm

Re: Trying to make an Tapas unlocker

Post by neroes » Sun Jun 22, 2025 6:12 pm

found out it only requires captchas if you login multiple times an hour and that we detect if the login is valid in an invalid way
the best way i found was to check if the AWSALB cookie had an expiry date that is higher than 1970

but i seem to have gotten it working though so thats great, just need to test it once the next set of WUF episodes comes tomorrow, and then also dockerize my solution

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests