maximedrn / opensea-automatic-bulk-upload-and-sale

A Selenium Python bot to automatically and bulk upload/ mint and list your NFTs on OpenSea. All metadata compatible, Ethereum and Polygon blockchains supported, reCAPTCHA solvers included.
GNU General Public License v3.0
326 stars 109 forks source link

Specific duration is broken when CSS is disabled. #385

Closed johnnyguitar77 closed 1 year ago

johnnyguitar77 commented 1 year ago

In its current state, the bot can not set the correct time to the listing. The reason is that one of the options being passed to Chrome is to block https://fonts.gstatic.com. By blocking those icons from loading, the name of the icons are displayed instead. The name is much larger than the icon itself, so when self.web.clickable('//*[@id="start-time') is called, the click is on the minutes of HH:MM instead of on whitespace which causes send.keys to start at MM instead of starting at HH. For example, if the time for when the listing starts should be 08:14 PM, and the time that the list page is opened is 12:00 PM, it sends '0814P' starting at the first 0 of 12:00 PM which causes a time of 12:08 AM.

Also, Open Sea only works on hours of 1-12, so time 00:MM should be converted to 12:MM AM by setting hour="12" if hour=="0".

maximedrn commented 1 year ago

Oh, I see. Thank you for that! I thought this feature wouldn't affect the script because I don't use CSS as a selector. I will change that!

Also, Open Sea only works on hours of 1-12, so time 00:MM should be converted to 12:MM AM by setting hour="12" if hour=="0".

It's already in the script, I'll take look to make sure it still works.

maximedrn commented 1 year ago

Edit: this should be fixed in the new version. I added Keys.ARROW_LEFT when it clicks on the input so that it starts from the hours.

Also, I fixed two errors with AM and PM:

johnnyguitar77 commented 1 year ago

Thank you for the update. I still have the same issue with 00 being typed instead of 12. Do you know where the code is that switches 00 to 12 so I can see if it's something wrong with my end?

Also, for me, hour += Keys.ARROW_RIGHT if len(hour) == 1 else '' leads to wrong results. The reason is that OpenSea automatically knows that if an hour of 2 or larger is typed, it should be 02 and automatically shifts over to the minutes. I think it should be hour += Keys.ARROW_RIGHT if int(hour) == 1 else '' and it should be outside the if statement of int(hour) > 12 since the issue only comes up if the hour is 01 or 1, and in both cases it needs a manual right arrow.

maximedrn commented 1 year ago

Hi, I reworked the function to use the old method. The calendar method is broken, so now it will use the inputs for the date. Can you try this code? And let me know if it works with your durations (it works for me):

# app/services/processes/sale.py - ~ line 249-250.

def send_date(self, element: str, duration: str) -> None:
    """Send the the specific duration."""
    from datetime import datetime as dt  # Python default import.
    date, time = duration.split(' ')  # Get the date and the time.
    time, clock = dt.strptime(  # 24h to 12h and get PM/ AM value.
        time, '%H:%M').strftime('%I:%M %p')[:-1].split(' ')
    day, month, year = date.split('-')  # Get the day, month and year.
    hour, minute = time.split(':')  # Split the hour and minute.
    year = '' if str(dt.now().year) == year else year  # Remove year.
    left, right, date, time = Keys.ARROW_LEFT, Keys.ARROW_RIGHT, [], []
    for key, part in enumerate([month.zfill(2), day.zfill(2), year]):
        date += [left] * 3 + [right] * key + [part]  # Date list.
    for key, part in enumerate([hour.zfill(2), minute.zfill(2), clock]):
        time += [left] * 3 + [right] * key + [part]  # Time list.
    self.web.clickable(f'//*[@id="{element}-date"]')  # Send date.
    [self.web.send_keys(  # Send the date in different part.
        f'//*[@id="{element}-date"]', part) for part in date]
    self.web.clickable(f'//*[@id="{element}-time"]')
    [self.web.send_keys(  # Send the time in different part.
        f'//*[@id="{element}-time"]', part) for part in time]
johnnyguitar77 commented 1 year ago

Sorry for the late response, I had gotten busy over the weekend. Everything is working perfectly now, thank you!