-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix latercera portada #625
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
"singleQuote": true, | ||
"semi": false, | ||
"printWidth": 120 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,13 +87,11 @@ const diarios = { | |
noSlashes: false | ||
}, | ||
tercera: { | ||
url: | ||
'https://edition.pagesuite-professional.co.uk/get_image.aspx?w=550&pbid=33084897-397a-48cc-b3c0-3ce1ec447137&pnum=01&nocache=#DATE#', | ||
url: 'https://kiosco.latercera.com/latest-issue-cover-image?collection=lt_diario_la_tercera_6_30&nocache=#DATE#', | ||
noSlashes: true | ||
}, | ||
cuarta: { | ||
url: | ||
'https://edition.pagesuite-professional.co.uk/get_image.aspx?w=550&pbid=a94a1c16-2ebc-4ecc-b2bc-d60709ea4c26&pnum=01&nocache=#DATE#', | ||
url: 'https://kiosco.lacuarta.com/latest-issue-cover-image?collection=lc_diario_la_cuarta&nocache=#DATE#', | ||
noSlashes: true | ||
}, | ||
estrellaarica: { | ||
|
@@ -301,46 +299,48 @@ const getPortada = (res, diario) => { | |
const fecha = moment().subtract(daysPast, 'days') | ||
testUrl = diario.url.replace('#DATE#', formatDate(fecha, diario.noSlashes)) | ||
return new Promise((resolve, reject) => { | ||
res | ||
.http(testUrl) | ||
.timeout(2000) | ||
.get()((err, response, body) => { | ||
if (err) return reject(err) | ||
switch (response.statusCode) { | ||
case 404: | ||
daysPast++ | ||
resolve(testUrl) | ||
break | ||
case 200: | ||
ready = false | ||
if (testUrl === endpointHxh) { | ||
try { | ||
var jsonHxh = JSON.parse(body) | ||
testUrl = jsonHxh[0].esPortadaFalsa || diario.forcePortada ? jsonHxh[3].img : jsonHxh[0].img | ||
const dateFromHxh = testUrl && testUrl.split('/')[4] | ||
dateFromHxh && sendPortadaDate(res, moment(dateFromHxh, 'DDMMYY').toDate()) | ||
resolve(testUrl) | ||
} catch (err) { | ||
reject(err) | ||
} | ||
} else { | ||
sendPortadaDate(res, fecha) | ||
res.http(testUrl).timeout(2000).get()((err, response, body) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No soy muy fan del estilo, pero la indentación debería ser igual al archivo original There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Entonces prettier no está configurado en el proyecto, no? @gmq |
||
if (err) return reject(err) | ||
switch (response.statusCode) { | ||
case 404: | ||
daysPast++ | ||
resolve(testUrl) | ||
break | ||
case 200: | ||
ready = false | ||
if (testUrl === endpointHxh) { | ||
try { | ||
var jsonHxh = JSON.parse(body) | ||
testUrl = jsonHxh[0].esPortadaFalsa || diario.forcePortada ? jsonHxh[3].img : jsonHxh[0].img | ||
const dateFromHxh = testUrl && testUrl.split('/')[4] | ||
dateFromHxh && sendPortadaDate(res, moment(dateFromHxh, 'DDMMYY').toDate()) | ||
resolve(testUrl) | ||
} catch (err) { | ||
reject(err) | ||
} | ||
break | ||
default: | ||
resolve() | ||
break | ||
} | ||
}) | ||
} else { | ||
sendPortadaDate(res, fecha) | ||
resolve(testUrl) | ||
} | ||
break | ||
case 302: | ||
PotterSys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ready = false | ||
sendPortadaDate(res, fecha) | ||
resolve(testUrl) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En este caso, debería devolver el header |
||
break | ||
default: | ||
resolve() | ||
break | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
) | ||
} | ||
|
||
module.exports = robot => { | ||
robot.respond(/portada (.*)/i, res => { | ||
module.exports = (robot) => { | ||
robot.respond(/portada (.*)/i, (res) => { | ||
const nombre = res.match[1] | ||
.toLowerCase() | ||
.replace(/^(las |la |el |le |the |o |il )/, '') | ||
|
@@ -361,11 +361,11 @@ module.exports = robot => { | |
res.send(listaPortadas()) | ||
} else if (nombre in diarios) { | ||
getPortada(res, diarios[nombre]) | ||
.then(result => { | ||
.then((result) => { | ||
if (!result) return res.send('No hay portada disponible') | ||
res.send(result) | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
robot.emit('error', err, res, 'portadas') | ||
}) | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5341,9 +5341,10 @@ preserve@^0.2.0: | |
version "0.2.0" | ||
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" | ||
|
||
[email protected]: | ||
version "1.12.1" | ||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325" | ||
[email protected]: | ||
version "2.0.5" | ||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" | ||
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg== | ||
Comment on lines
+5344
to
+5347
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esta magia debería estar en un PR aparte |
||
|
||
pretty-ms@^0.2.1: | ||
version "0.2.2" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Un version bump debería estar en un PR aparte
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
De hecho este cambio completo debería ser un PR aparte, no es de latercera este cambio?