Skip to content

Commit 51587f9

Browse files
committed
deleted redundant function
1 parent 097d6bc commit 51587f9

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

julia/consoles.jl

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
include("utils.jl")
22

3-
search(session, x::String) = script!(session, "document.getElementById('search_form_input').value = '" * x * "'; document.getElementById('search_form_input').form.submit();")
4-
53
url(::Val{PlayStation}) = "https://store.playstation.com/en-us/"
6-
url(::Val{Xbox}) = "https://www.xbox.com/en-US/games/store/"
7-
url(::Val{Switch}) = "https://www.nintendo.com/us/store/"
8-
url(::Val{Epic}) = "https://store.epicgames.com/en-US/"
9-
url(::Val{GOG}) = "https://www.gog.com/en/game/"
4+
url(::Val{Xbox}) = "https://www.xbox.com/en-US/games/store/"
5+
url(::Val{Switch}) = "https://www.nintendo.com/us/store/"
6+
url(::Val{Epic}) = "https://store.epicgames.com/en-US/"
7+
url(::Val{GOG}) = "https://www.gog.com/en/game/"
108
url(x::Platform) = url(Val(x))
119

1210
function search_console(session, console::String, str::String,)
13-
search(session, console*" "*str)
11+
script!(session, "document.getElementById('search_form_input').value = '" * console * " " * str * "'; document.getElementById('search_form_input').form.submit();")
1412
sleep(2)
1513
html = source(session) |> parse_html
1614
res = html_attrs(html_elements(html, [".pAgARfGNTRe_uaK72TAD", "a"]), "href")
1715
return res[1:3]
1816
end
1917

20-
function read_html_epic(session,url)
18+
function read_html_epic(session, url)
2119
navigate!(session, url)
2220
sleep(1.5)
2321
return parse_html(source(session))
@@ -39,11 +37,11 @@ function get_true_link(links::Vector{String}, platform::Platform, name::String):
3937
return ""
4038
end
4139

42-
get_name(::Val{PlayStation}, html) = html_text3(html_elements(html,[".psw-c-bg-0","h1"]))[1]
43-
get_name(::Val{Xbox}, html) = html_text3(html_elements(html,"h1"))[1]
44-
get_name(::Val{Switch}, html) = split(html_text3(html_elements(html,"title")[1])," for Nintendo")[1]
45-
get_game(::Val{Epic}, html) = html_text3(html_elements(html,"h1")[1])
46-
get_name(::Val{GOG}, html) = (html_elements(html,".game-info__title"))[1].children[1].text |> strip
40+
get_name(::Val{PlayStation}, html) = html_text3(html_elements(html, [".psw-c-bg-0", "h1"]))[1]
41+
get_name(::Val{Xbox}, html) = html_text3(html_elements(html, "h1"))[1]
42+
get_name(::Val{Switch}, html) = split(html_text3(html_elements(html, "title")[1]), " for Nintendo")[1]
43+
get_game(::Val{Epic}, html) = html_text3(html_elements(html, "h1")[1])
44+
get_name(::Val{GOG}, html) = (html_elements(html, ".game-info__title"))[1].children[1].text |> strip
4745

4846
function add_console()
4947
sessions::Vector{Session} = [Session(wd) for _ in 1:Threads.nthreads()]
@@ -53,23 +51,23 @@ function add_console()
5351
@showprogress Threads.@threads for unique_country in unique(df[:, :Country])
5452
temp_df = df[df[:, :Country].==unique_country, :]
5553
for i in 1:nrow(temp_df)
56-
name = temp_df[i,:Name]
54+
name = temp_df[i, :Name]
5755

5856
platforms = [
59-
(enum = PlayStation, column = :PlayStation_Link),
60-
(enum = Xbox, column = :Xbox_Link),
61-
(enum = Switch, column = :Switch_Link),
62-
(enum = GOG, column = :GOG_Link)
57+
(enum=PlayStation, column=:PlayStation_Link),
58+
(enum=Xbox, column=:Xbox_Link),
59+
(enum=Switch, column=:Switch_Link),
60+
(enum=GOG, column=:GOG_Link)
6361
]
6462

6563
for platform in platforms
66-
if (temp_df[i,platform.column] == "Unknown")
64+
if (temp_df[i, platform.column] == "Unknown")
6765
links = search_console(sessions[Threads.threadid()], url(platform.enum), name)
68-
temp_df[i,platform.column] = get_true_link(links, platform.enum, name)
66+
temp_df[i, platform.column] = get_true_link(links, platform.enum, name)
6967
end
7068
end
7169

72-
save_data(temp_df,unique_country)
70+
save_data(temp_df, unique_country)
7371
end
7472
end
7573
end

0 commit comments

Comments
 (0)