Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(playstation): add queuing selector #1173

Merged
merged 3 commits into from
Dec 11, 2020
Merged

feat(playstation): add queuing selector #1173

merged 3 commits into from
Dec 11, 2020

Conversation

willwhitney
Copy link
Contributor

Description

Addresses #1049 by checking for the queue information bullet points when visiting the Playstation Store.

Testing

Ran streetmerchant while there was a queue at the PS store. Observed notifications.

@willwhitney willwhitney requested a review from jef as a code owner December 4, 2020 21:37
Copy link
Owner

@jef jef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a new store, do you mind adding to the inStock array?

You can add by doing this:

diff --git a/src/store/model/playstation.ts b/src/store/model/playstation.ts
--- a/src/store/model/playstation.ts
+++ b/src/store/model/playstation.ts
@@ -3,10 +3,16 @@ import fetch from 'node-fetch';
 
 export const PlayStation: Store = {
 	labels: {
-		inStock: {
+		inStock: [
+			{
 			container: '.productHero-info .add-to-cart:not(.hide)',
 			text: ['Add']
-		},
+			},
+			{
+				container: '.bulleted-info.queue',
+				text: ['queue']
+			}
+		],
 		outOfStock: {
 			container: '.productHero-info .out-stock-wrpr:not(.hide)',
 			text: ['Out of Stock']

Other than that, thank you updating!

@willwhitney
Copy link
Contributor Author

Ah cool, I didn't know that could be a list. Adding this could lead to some false positives for people who have added the Playstation store but on balance it's a pretty good signal.

@kenbalint
Copy link

kenbalint commented Dec 6, 2020

Would this still work even if you get the softblock captcha page? After running the script for a few minutes on the ps5 website, it hits this "We're trying to get you in" captcha page (eg. https://direct-queue.playstation.com/softblock/?c=sonyied&e=psdirectprodku1), does the queue checking work even if it gets hit with this captcha? Or would we have to solve the captcha ourselves every so often to keep it alive

Edit 12/8/2020: Would like to report that this fork worked perfectly today on the ps5 queue.
image

@symourjr
Copy link

symourjr commented Dec 9, 2020

Would this still work even if you get the softblock captcha page? After running the script for a few minutes on the ps5 website, it hits this "We're trying to get you in" captcha page (eg. https://direct-queue.playstation.com/softblock/?c=sonyied&e=psdirectprodku1), does the queue checking work even if it gets hit with this captcha? Or would we have to solve the captcha ourselves every so often to keep it alive

Edit 12/8/2020: Would like to report that this fork worked perfectly today on the ps5 queue.
image

Have more info on how to get this implemented? Queue went up today and did not get in on time.

@kenbalint
Copy link

kenbalint commented Dec 9, 2020

It didn't alert me for today's queue- but I think it might be due to the fact that my instance was one of the first to access the site at the time the queue went up, therefore bypassing the queue? I was running non-headless and I saw it was still able to access the product page perfectly fine, which is why I come to that conclusion. With that being said, it might be hit or miss if this works at times.

For implementation, until this gets pushed into the main branch, you'd have to clone willwhitney's repo, and follow the same instructions as a normal install. In your .env file you would put SHOW_ONLY_SERIES="sonyps5c,sonyps5de" and STORES="playstation-queue"

I believe that was all I had to do to get it working.

@TheEmpty
Copy link

TheEmpty commented Dec 9, 2020 via email

@kenbalint
Copy link

you need to not persist cookies to check queue

On Wed, Dec 9, 2020 at 1:47 PM kenbalint @.***> wrote: It didn't alert me for today's queue- but I think it might be due to the fact that it was one of the first to access the site, therefore bypassing the queue? I was running non-headless and I saw it was still able to access the product page perfectly fine, which is why I come to that conclusion. With that being said, it might be hit or miss if this works at times. For implementation, until this gets pushed into the main branch, you'd have to clone willwhitney's repo, and follow the same instructions as a normal install. In your .env file you would put SHOW_ONLY_SERIES="sonyps5c,sonyps5de" and STORES="playstation-queue" I believe that was all I had to do to get it working. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1173 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC2ZZEMLMVW6EQYTCUY4CDST7V6TANCNFSM4UN7R3EA .
-- محمد Τυπάλδος

Yes, forcing it to re-create cookies every time would work to ensure it checks queue.

I personally have not checked too far into this repository so I am unsure if this is a pre built-in functionality, but I assume with selenium, removing cookies should not be difficult.

@jef
Copy link
Owner

jef commented Dec 11, 2020

So what seems to be to verdict here? Should we consolidate or should we keep as-is and fix the linting issues?

Not sure if I follow the comments 😞

@willwhitney
Copy link
Contributor Author

@kenbalint does the change proposed by @jef take care of this? If the browser already has cookies that get it into the store, would it simply report that the console is available from seeing the page?

Relatedly, if the browser has already recently visited the store before the queue goes up, could this let us bypass the queue entirely for purchasing?

@jef
Copy link
Owner

jef commented Dec 11, 2020

Relatedly, if the browser has already recently visited the store before the queue goes up, could this let us bypass the queue entirely for purchasing?

This I don't know. It's entirely up to how Sony handles their queuing system.

If a queue is ready, this would at least alert the user to open the browser (or open it for you, depending on settings). As for joining the queue, I'm not sure.

If you're asking if the Chromium browser keeps the cookies, yes -- it does. Unless you're using INCOGNITO=true, then it won't (from my understanding on how puppeteer works).

Copy link
Owner

@jef jef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Thank you very much :-)

Awesome work here!

@jef jef changed the title feat: add PlaystationQueue store feat(playstation): add queuing selector Dec 11, 2020
@jef jef merged commit 67b19a7 into jef:main Dec 11, 2020
@kenbalint
Copy link

kenbalint commented Dec 12, 2020

@kenbalint does the change proposed by @jef take care of this? If the browser already has cookies that get it into the store, would it simply report that the console is available from seeing the page?

Unfortunately, the stock drops later than the queue itself, so it will not immediately report that the console is available from seeing the page.

Relatedly, if the browser has already recently visited the store before the queue goes up, could this let us bypass the queue entirely for purchasing?

I tested this theory today, I got through the queue "bypassed" as one could say, but unfortunately I don't think this would work for checking out, as it kicked me out of the queue later on (probably since I was on the product page for 10 minutes, which is how long they give you to check out) and forced me to solve a captcha and get a new place in line.

Best bet would be to have it so that it just throws away cookies every time it closes the page, so that it starts fresh on each reload if that's possible with the current api / implementations.

With new cookies every time, it would certainly get a queue message when the queue comes live, and there is no chance that it loads the product page instead of the queue page, thus skipping any alerts.

ven0ms99 pushed a commit to ven0ms99/streetmerchant that referenced this pull request Dec 12, 2020
@jef
Copy link
Owner

jef commented Dec 14, 2020

With new cookies every time, it would certainly get a queue message when the queue comes live, and there is no chance that it loads the product page instead of the queue page, thus skipping any alerts.

If this is the case, run streetmerchant with INCOGNITO=true and see what you get out of it. You might be downloaded more data, but check that out.

I forget right now if we destroy cookies or not everytime, but perhaps we should do this by default. Maybe not caching (keep using INCOGNITO), but I don't see cookies being relevant in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants