Skip to content

Commit

Permalink
change to expect
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghaisheng committed Nov 28, 2023
1 parent fd7251a commit f406ce9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions tsup/utils/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import random
from datetime import datetime, date, timedelta, time
from playwright.async_api import Page, expect
from tsup.youtube.youtube_helper import set_channel_language_english
import sys
""" Login module """

Expand Down Expand Up @@ -174,20 +175,20 @@ async def passwordlogin(self, page):

else:
self.logger.debug("change sign in display language to english")

try:
await page.get_by_role("combobox").is_visible()
s = await page.get_by_role("combobox").all_text_contents()
#endpoint > tp-yt-paper-item > yt-formatted-string
await page.locator("#endpoint > tp-yt-paper-item > yt-formatted-string").is_visible()
s = await page.locator("#endpoint > tp-yt-paper-item > yt-formatted-string").all_text_contents()
s = "".join(s)
if not "English" in s:
await page.get_by_role("combobox").click()
await page.get_by_role("option", name="English (United States)").click()
if not "Home" in s:
await set_channel_language_english(self, page)

self.logger.debug("changed to english display language")

except:
self.logger.debug("could not find language option ")
await self.pl.quit()
# #sys.exit(1)
#sys.exit(1)

sleep(random.uniform(5, 6))

Expand Down
3 changes: 2 additions & 1 deletion tsup/youtube/youtube_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ async def upload(
except Exception as e:
self.logger.error(f"can not access {YoutubeHomePageURL} due to {e}")
await self.pl.quit()
sys.exit(1)
# sys.exit(1)
return False,None

page = self.page
islogin = False
Expand Down

0 comments on commit f406ce9

Please sign in to comment.