This commit is contained in:
tree 2022-01-06 06:49:50 +01:00
rodič 6de1ba3a50
revize 338b341b1a
6 změnil soubory, kde provedl 36 přidání a 8 odebrání

Binární soubor nebyl zobrazen.

Za

Šířka:  |  Výška:  |  Velikost: 151 KiB

Binární soubor nebyl zobrazen.

Za

Šířka:  |  Výška:  |  Velikost: 39 KiB

Binární soubor nebyl zobrazen.

Za

Šířka:  |  Výška:  |  Velikost: 15 KiB

Zobrazit soubor

@ -1,4 +1,4 @@
import { emptyDir } from 'https://deno.land/std@0.119.0/fs/mod.ts'
import { emptyDir, exists } from 'https://deno.land/std@0.119.0/fs/mod.ts'
import { copy } from 'https://deno.land/std@0.119.0/fs/copy.ts'
import { load } from 'https://deno.land/x/js_yaml_port@3.14.0/js-yaml.js'
@ -20,6 +20,10 @@ export class UTXOEngine {
if (!this.options.silent) {
console.log(banner)
}
this.imageTypes = [
[ 'sm', 'png' ],
[ 'twitter', 'jpg' ]
]
}
async init () {
@ -39,6 +43,22 @@ export class UTXOEngine {
entry.specs = {}
for (const sp of entry.index.specDef) {
entry.specs[sp.type] = await this._yamlLoad([specDir, `${sp.type}.yaml`].join('/'))
// post processing of sub-specs
switch(sp.type) {
case 'speakers':
for (const s of entry.specs[sp.type]) {
if (!s.photos) {
s.photos = []
}
for (const [ it, format ] of this.imageTypes) {
if(await exists([ this.srcDir, f.name, 'photos', 'speakers', `${s.id}-${it}.${format}` ].join('/'))) {
s.photos.push(`${it}:${format}`)
}
}
}
break
}
}
}
if (!this.options.silent) {

Zobrazit soubor

@ -2,6 +2,9 @@ type: array
items:
type: object
additionalProperties: false
required:
- id
- name
properties:
id:
type: string
@ -31,3 +34,5 @@ items:
type: array
items:
type: string
photos:
type: array

Zobrazit soubor

@ -35,13 +35,16 @@ for (const sp of entry.specs.speakers) {
continue
}
const url = tw.profile_image_url_https.replace('_normal', '')
console.log(url)
const res = await fetch(url)
const file = await Deno.open(twitterImagesPath + sp.id + '-twitter.jpg', { create: true, write: true })
const reader = fromStreamReader(res.body.getReader())
await Deno.copy(reader, file)
file.close()
const imageFn = twitterImagesPath + sp.id + '-twitter.jpg'
if (!await exists(imageFn)) {
const url = tw.profile_image_url_https.replace('_normal', '')
console.log(url)
const res = await fetch(url)
const file = await Deno.open(imageFn, { create: true, write: true })
const reader = fromStreamReader(res.body.getReader())
await Deno.copy(reader, file)
file.close()
}
arr.push([ tw.screen_name, tw.followers_count ])
total += tw.followers_count