Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gu imageworks extension
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
joetsuihk
gu imageworks extension
Commits
b2d6d63f
Commit
b2d6d63f
authored
Feb 21, 2022
by
edwin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change fetch behavior from enter sku to enter url, update download all logic
parent
6171c913
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
fetch.js
fetch/fetch.js
+22
-20
No files found.
fetch/fetch.js
View file @
b2d6d63f
...
...
@@ -2,7 +2,7 @@
const
baseurl
=
"https://digitallibrary-external.fastretailing.com/"
;
const
fetchNumber
=
30
;
const
sleepTime
=
25
00
;
const
sleepTime
=
30
00
;
let
allowDebugMessage
=
true
;
// adding the lightbox (control panel) to the body
...
...
@@ -87,7 +87,8 @@
document
.
querySelector
(
"#fetch-lightbox .info-message"
).
innerHTML
=
""
;
for
(
let
SKU
of
SKUlist
)
{
let
assetlist
=
await
fetchSKU
(
SKU
);
let
currentms
=
new
Date
().
getTime
();
let
assetlist
=
await
fetchSKU
(
SKU
,
`
${
baseurl
}
api/asset?time=
${
currentms
}
&t=datacategory%2Fasset&w=
${
SKU
}
&r=north&z=
${
fetchNumber
}
&c=DEFAULT`
);
// determine whether it is product file
...
...
@@ -176,10 +177,19 @@
document
.
querySelector
(
"#fetch-lightbox .info-message"
).
innerHTML
=
""
;
for
(
let
SKU
of
SKUlist
)
{
let
assetlist
=
await
fetchSKU
(
SKU
);
let
downloadlist
=
filtering
(
assetlist
,
SKU
);
await
downloadList
(
downloadlist
[
"product"
],
`
${
SKU
}
`
);
let
currentms
=
new
Date
().
getTime
();
// old
// let assetlist = await fetchSKU(SKU, `${baseurl}api/asset?time=${currentms}&t=datacategory%2Fasset&w=${SKU}&r=north&z=${fetchNumber}&et=hk&c=DEFAULT`);
// new
let
assetlist
=
await
fetchSKU
(
SKU
,
`
${
baseurl
}
api/asset?time=
${
currentms
}
&t=main_product%2FGU%2F
${
SKU
}
&t=datacategory%2Fecasset&r=north&z=
${
fetchNumber
}
&et=hk&c=DEFAULT`
);
await
downloadList
(
assetlist
,
`
${
SKU
}
`
);
await
sleep
(
sleepTime
);
// &t=datacategory%2Fasset&w=341947&r=north&z=30&c=DEFAULT
currentms
=
new
Date
().
getTime
();
assetlist
=
await
fetchSKU
(
SKU
,
`
${
baseurl
}
api/asset?time=
${
currentms
}
&t=datacategory%2Fasset&w=
${
SKU
}
&r=north&z=
${
fetchNumber
}
&c=DEFAULT`
);
let
downloadlist
=
filtering
(
assetlist
,
SKU
);
await
downloadList
(
downloadlist
[
"model"
],
`
${
SKU
}
_model`
);
await
sleep
(
sleepTime
);
}
...
...
@@ -189,15 +199,12 @@
}
//grabbing single SKU data
async
function
fetchSKU
(
SKU
=
""
)
{
if
(
SKU
.
length
==
0
)
{
async
function
fetchSKU
(
SKU
,
url
=
""
)
{
if
(
SKU
.
length
==
0
||
url
.
length
==
0
)
{
return
;
}
let
currentms
=
new
Date
().
getTime
();
let
url
=
`
${
baseurl
}
api/asset?time=
${
currentms
}
&t=datacategory%2Fasset&w=
${
SKU
}
&r=north&z=
${
fetchNumber
}
&c=DEFAULT`
;
let
config
=
getConfig
();
addDebugMessage
(
`Start fetching SKU=
${
SKU
}
`
);
return
await
fetch
(
url
,
config
)
...
...
@@ -270,19 +277,14 @@
assetlist
=
assetlist
.
filter
(
asset
=>
asset
.
file_extension
===
"jpg"
||
asset
.
file_extension
===
"gif"
);
let
multilist
=
assetlist
.
reduce
(
function
(
arrlist
,
item
)
{
let
tagid
=
item
.
tags
.
map
(
x
=>
x
.
id
);
if
(
item
.
filename
.
includes
(
`goods_
${
SKU
}
_sub`
)
||
item
.
filename
.
includes
(
`_
${
SKU
}
_chip`
)
||
(
item
.
filename
.
match
(
new
RegExp
(
`^goods_[0-9]{2}_
${
SKU
}
$`
))
&&
item
.
models
.
length
===
0
&&
item
.
products
.
length
===
1
))
{
// file name include SKU and no model
arrlist
[
"product"
].
push
(
item
);
}
else
if
(
item
.
filename
.
includes
(
`
${
SKU
}
_I0`
)
||
(
item
.
filename
.
includes
(
"goods"
)
&&
!
item
.
filename
.
includes
(
SKU
))
||
item
.
tags
.
map
(
x
=>
x
.
id
).
includes
(
"assettype/Poster"
)
||
item
.
filename
.
includes
(
"GU_"
))
{
if
(
item
.
filename
.
includes
(
"GU_"
))
{
// not adding to model
}
else
{
}
else
if
(
tagid
.
includes
(
"Appeal POP"
)
||
tagid
.
includes
(
"Model"
))
{
arrlist
[
"model"
].
push
(
item
);
}
return
arrlist
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment