Skip to content

Commit

Permalink
Create xcloud_extras_picker
Browse files Browse the repository at this point in the history
To get the rencently added games on Game Pass
  • Loading branch information
LuanRoger committed Oct 19, 2022
1 parent 3cc4c84 commit dfea229
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 15 deletions.
1 change: 1 addition & 0 deletions tools/internals/shared_consts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
XCLOUD_BASE_URL: str = "https://www.xbox.com/"
4 changes: 4 additions & 0 deletions tools/internals/utils/url_formater.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
def add_formater_game_url_server(url: str, base_url: str) -> str:
return base_url + "%s/" + url[len(base_url):]

def add_parameter_sprinter(url: str) -> str:
if(url is None): return None

Expand All @@ -13,6 +16,7 @@ def add_parameter_sprinter(url: str) -> str:
arguments = arguments.replace(height, "%i", 1)

return url[:argument_start] + arguments

def format_hero_image(url: str) -> str:
if(url is None): return None

Expand Down
3 changes: 2 additions & 1 deletion tools/xcloud_extras/consts.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
XCLOUD_RECENTLY_ADDED_URL: str = "https://www.xbox.com/pt-BR/play/gallery/recently-added"
XCLOUD_RECENTLY_ADDED_URL: str = "https://www.xbox.com/pt-BR/play/gallery/recently-added"
RECENTLY_ADDED_JSON_FILE: str = "./xcloud_recents.json"
25 changes: 17 additions & 8 deletions tools/xcloud_extras_picker.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
from time import sleep
from typing import List
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from internals.models.xcloud_game import XcloudGame

from xcloud_extras.consts import XCLOUD_RECENTLY_ADDED_URL
from internals.element_picker import getGamesInGrid
from xcloud_extras.consts import *
from internals.shared_consts import XCLOUD_BASE_URL
from internals.element_picker import getGamesInGrid, getGamesInfoInNewTab
from internals.webdriver_utils import *
from internals.xcloud_elements_consts import *
from internals.json_writer import *
from utils.url_formater import *
from internals.utils.url_formater import *

driver = webdriver.Edge()
driver.get(XCLOUD_RECENTLY_ADDED_URL)
games_grid = driver.find_element(by=By.CLASS_NAME, value=GAMES_GRID_ELEMENT)
games = getGamesInGrid(games_grid)

games_list: List[XcloudGame] = []
for game in games:
game_url:str = game.get_attribute("href")
game_url: str = game.get_attribute("href")
game_image_element = game.find_element(by=By.TAG_NAME, value="img")
tile_image_url = add_parameter_sprinter(game_image_element.get_attribute("src"))
tile_image_url = add_parameter_sprinter(game_image_element.get_attribute("src"))

xcloud_game = getGamesInfoInNewTab(driver, game_url)
xcloud_game.xcloudUrl = add_formater_game_url_server(game_url, XCLOUD_BASE_URL)
xcloud_game.tileGameImageUrl = tile_image_url

games_list.append(xcloud_game)

driver.close()
flush_game_list(games_list, RECENTLY_ADDED_JSON_FILE)
1 change: 0 additions & 1 deletion tools/xcloud_game/consts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
XCLOUD_BASE_URL: str = "https://www.xbox.com/"
XCLOUD_URL: str = "https://www.xbox.com/en-US/play/gallery/all-games"
GAMES_JSON_FILE_PATH: str = "./xcloud_games.json"
7 changes: 2 additions & 5 deletions tools/xcloud_game_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from internals.utils.url_formater import *
from xcloud_game.consts import *
from internals.shared_consts import XCLOUD_BASE_URL
from internals.element_picker import getGamesInfoInNewTab, getGamesInGrid
from internals.webdriver_utils import *
from internals.xcloud_elements_consts import *
Expand All @@ -17,10 +18,6 @@
games_grid = driver.find_element(by=By.CLASS_NAME, value=GAMES_GRID_ELEMENT)
done: bool = False

def add_formater_game_url_server(url: str) -> str:
base_url = XCLOUD_BASE_URL
return base_url + "%s/" + url[len(base_url):]

page_scroll_point = 0
page_height = driver.execute_script("return document.body.scrollHeight")
games_list: List[XcloudGame] = []
Expand All @@ -36,7 +33,7 @@ def add_formater_game_url_server(url: str) -> str:
xcloud_game = getGamesInfoInNewTab(driver, game_url)
if(xcloud_game == None):
continue
xcloud_game.xcloudUrl = add_formater_game_url_server(game_url)
xcloud_game.xcloudUrl = add_formater_game_url_server(game_url, XCLOUD_BASE_URL)
xcloud_game.tileGameImageUrl = tile_image_url

if(xcloud_game not in games_list):
Expand Down
271 changes: 271 additions & 0 deletions tools/xcloud_recents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
[
{
"gameTitle": "A Plague Tale: Requiem",
"gamePublisher": "Focus Entertainment",
"gameDeveloper": "Asobo Studio",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"RPG"
],
"releaseDate": "18/10/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/a-plague-tale-requiem/9ND0JVB184XL",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.60562.13558336166432541.beb57fbe-cc4b-40c5-ba76-c8112867dea2.9a69e497-4f9f-495d-9ac6-f8956b491d91?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.59830.13558336166432541.beb57fbe-cc4b-40c5-ba76-c8112867dea2.f764a45c-f860-483f-b264-aa9041f2bb62?h=%i&format=jpg"
},
{
"gameTitle": "Beacon Pines",
"gamePublisher": "Fellow Traveller",
"gameDeveloper": "Hiding Spot",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"Fam\u00edlia e crian\u00e7as"
],
"releaseDate": "22/09/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/beacon-pines/9P4R2M0NRWNK",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.23560.14588206397851258.078192f2-519f-4a81-b68d-2dbd6199f2c2.af953250-54af-4a2a-be0c-163b68917421?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.39650.14588206397851258.078192f2-519f-4a81-b68d-2dbd6199f2c2.0f659ae9-51f1-4a1d-a086-0a5f165d5b5f?h=%i&format=jpg"
},
{
"gameTitle": "Chivalry 2",
"gamePublisher": "Tripwire Interactive LLC",
"gameDeveloper": "Torn Banner Studios",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"Luta"
],
"releaseDate": "08/06/2021",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/chivalry-2/9N7CJX93ZGWN",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.61947.14071745200459129.81e3e86f-3ab4-4027-b9a1-81f595fcb505.fc2487e4-7785-4a73-b2ad-b94aa01a7e7f?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.56595.14071745200459129.81e3e86f-3ab4-4027-b9a1-81f595fcb505.bcc44c15-cee0-4c07-a92c-766beb8fb174?h=%i&format=jpg"
},
{
"gameTitle": "Costume Quest",
"gamePublisher": "THQ, Inc.",
"gameDeveloper": "Double Fine Productions, Inc.",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"RPG"
],
"releaseDate": "19/10/2010",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/costume-quest/BR74RLMH966K",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.18636.69532389726997442.230b98e2-1f17-47ab-9d5a-06afb771f0de.57d2c274-ba74-4d0a-a98f-24a4ca808a82?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.47121.69532389726997442.230b98e2-1f17-47ab-9d5a-06afb771f0de.a4b185ec-6d05-4391-9919-046299c7651b?h=%i&format=jpg"
},
{
"gameTitle": "DEATHLOOP",
"gamePublisher": "Bethesda Softworks",
"gameDeveloper": "Arkane Studios",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"Jogos de tiros"
],
"releaseDate": "20/09/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/deathloop/9P5Z4530318L",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.5858.14634955238674857.649b7ff9-0dfc-4951-9b65-c5d815215da6.90208516-ba3b-47a9-a130-ef94cf860f5b?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.26641.14634955238674857.649b7ff9-0dfc-4951-9b65-c5d815215da6.bacdd878-0313-4c58-9434-459afd7cf535?h=%i&format=jpg"
},
{
"gameTitle": "Despot's Game",
"gamePublisher": "tinyBuild",
"gameDeveloper": "Konfa Games",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"Outros"
],
"releaseDate": "29/09/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/despot's-game/9P5ZDVMCJMFD",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.54530.14634731171917513.ee44ea98-341d-42e8-b67a-c2a4254a08a0.3a8876e7-694c-40d5-8efc-0264051414e8?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.13399.14634731171917513.ee44ea98-341d-42e8-b67a-c2a4254a08a0.4239454b-8c5a-4424-b410-2039ca63a84c?h=%i&format=jpg"
},
{
"gameTitle": "Eville",
"gamePublisher": "Versus Evil, LLC.",
"gameDeveloper": "VestGames",
"gameGenres": [
"Outros",
"RPG"
],
"releaseDate": "11/10/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/eville/9PC12991NZ5N",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.31296.14112988465880137.944f8dc0-63f1-4f15-96aa-cab88a628053.65e7f8f4-3625-4a09-8aa7-fead27a7806f?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.19828.14112988465880137.944f8dc0-63f1-4f15-96aa-cab88a628053.3baaa95c-7788-4c73-aef5-b1cd1bd840b6?h=%i&format=jpg"
},
{
"gameTitle": "Grounded",
"gamePublisher": "Xbox Game Studios",
"gameDeveloper": "Obsidian Entertainment",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"RPG"
],
"releaseDate": "27/09/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/grounded/9PJTHRNVH62H",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.36912.14280109286674604.94f3a3e8-211f-41e5-ac9c-d948b5377852.4e9bf257-12e0-4f04-9239-671818df45b0?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.27514.14280109286674604.1fb359e4-01eb-4818-b992-b225ce4869c9.c9733025-0344-4e66-aff1-ee3bcf9016a7?h=%i&format=jpg"
},
{
"gameTitle": "Hardspace: Shipbreaker",
"gamePublisher": "Focus Entertainment",
"gameDeveloper": "Blackbird Interactive",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"Simula\u00e7\u00e3o"
],
"releaseDate": "20/09/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/hardspace-shipbreaker/9ND8C4314ZZG",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.11359.13552902647075103.9e24872e-3f43-4078-8279-1ddf37a77ab1.795f17b4-3acd-4226-91d9-5c6031d7899e?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.36125.13552902647075103.9e24872e-3f43-4078-8279-1ddf37a77ab1.246fb260-7ac0-4916-867b-dce60a943024?h=%i&format=jpg"
},
{
"gameTitle": "Let's Build a Zoo",
"gamePublisher": "No More Robots",
"gameDeveloper": "Springloaded",
"gameGenres": [
"Simula\u00e7\u00e3o",
"Estrat\u00e9gia"
],
"releaseDate": "28/09/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/let's-build-a-zoo/9P8N66DTG10T",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.63900.14084512162357210.0d6eea09-167f-4aad-97d7-d4d17f848799.2a1722e7-328d-4bb3-b556-0d4acae1567b?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.15530.14084512162357210.0d6eea09-167f-4aad-97d7-d4d17f848799.9a461717-eb83-4a42-875e-7c96139197b1?h=%i&format=jpg"
},
{
"gameTitle": "Medieval Dynasty",
"gamePublisher": "Toplitz Productions",
"gameDeveloper": "Render Cube",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"RPG"
],
"releaseDate": "06/10/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/medieval-dynasty/9PDDP6ML6XHF",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.26306.14156112272410024.03b91df3-d826-4d77-a692-6b75d9b18188.14e344a6-e6f9-43bd-8f8d-f6e965429119?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.63309.14156112272410024.03b91df3-d826-4d77-a692-6b75d9b18188.85b2f37e-0bd7-4de5-a925-bc86f2c59896?h=%i&format=jpg"
},
{
"gameTitle": "Moonscars",
"gamePublisher": "Humble Games",
"gameDeveloper": "Black Mermaid",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"Plataforma"
],
"releaseDate": "27/09/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/moonscars/9P77VD8MGJX8",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.48607.14609228948314679.57b5d232-e029-48c3-a08c-a51885c8f604.a75be4f6-a08c-465f-8452-bf3c2ee5da75?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.16286.14609228948314679.57b5d232-e029-48c3-a08c-a51885c8f604.af5bedd3-16ab-4c9d-a23d-deda8b3b585f?h=%i&format=jpg"
},
{
"gameTitle": "Patrulha Canina: Grand Prix",
"gamePublisher": "Outright Games Ltd.",
"gameDeveloper": "3DClouds",
"gameGenres": [
"Fam\u00edlia e crian\u00e7as",
"A\u00e7\u00e3o e aventura"
],
"releaseDate": "29/09/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/patrulha-canina-grand-prix/9MWBT3HFCZ3Z",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.30417.13842132658396836.fba80705-9bc9-45ad-84f9-621f75fe99ec.63412d4a-24e5-449a-9622-75435adb7a73?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.53527.13842132658396836.fba80705-9bc9-45ad-84f9-621f75fe99ec.a7d39a33-f2c3-408b-a88d-4ef40eb5c446?h=%i&format=jpg"
},
{
"gameTitle": "Prodeus",
"gamePublisher": "Humble Games",
"gameDeveloper": "Bounding Box Software Inc.",
"gameGenres": [
"A\u00e7\u00e3o e aventura",
"Jogos de tiros"
],
"releaseDate": "23/06/2021",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/prodeus/9MZRSLLWKWDV",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.25232.13864617007662897.01825ec5-fdc1-49fc-a5ac-f29f1860b3d2.5ab6a036-6d65-44b6-9ac8-7dba4e646ad1?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.9406.13864617007662897.01825ec5-fdc1-49fc-a5ac-f29f1860b3d2.4de0b1f4-bc29-45f6-9f06-cb0449d3d4d3?h=%i&format=jpg"
},
{
"gameTitle": "Scorn",
"gamePublisher": "Kepler Interactive",
"gameDeveloper": "Ebb Software",
"gameGenres": [
"A\u00e7\u00e3o e aventura"
],
"releaseDate": "14/10/2022",
"extraGameProperties": {
"isInGamePass": true,
"controllerSupport": false,
"touchControllerSupport": false
},
"xcloudUrl": "https://www.xbox.com/%s/play/games/scorn/9NM3TNRPQXLR",
"tileGameImageUrl": "https://store-images.s-microsoft.com/image/apps.51381.13699799412731780.9f7b812e-456c-430e-8cec-380f1ca9e4a2.dd9f4725-f6e0-4fe4-9484-9d5f22682786?w=%i&h=%i",
"gameImageUrl": "https://store-images.s-microsoft.com/image/apps.16661.13699799412731780.1afb5b8c-d3cf-40b3-aa5e-f5e01adefd6c.71e32c0e-4c10-4a4b-a813-3478373b1769?h=%i&format=jpg"
}
]

0 comments on commit dfea229

Please sign in to comment.