improve image capture

This commit is contained in:
Tykayn 2022-12-14 16:47:57 +01:00 committed by tykayn
parent bd8095e822
commit 0e17ab9c6f
4 changed files with 11 additions and 19 deletions

View File

@ -1,6 +1,11 @@
import fs from "fs";
import path from 'path';
import sendPostMastodon, {randomIntFromInterval, findFirstImageInContent, findPictureAndSendPost} from './utils.mjs'
import sendPostMastodon, {
randomIntFromInterval,
findFirstImageInContent,
findPictureAndSendPost,
getRandomElementOfArray
} from './utils.mjs'
const __dirname = path.resolve();
const tkpostsjson = JSON.parse(fs.readFileSync(__dirname + "/assets/documents/cipherbliss_tkwp_posts.json", 'utf-8'))
@ -8,10 +13,6 @@ let reallySendPost = false;
// reallySendPost = true;
export function getRandomElementOfArray(listItems) {
return listItems[Math.floor(Math.random() * listItems.length)]
}
function getRandomLink() {
let filteredLinks = tkpostsjson.filter(elem => elem.post_status === 'publish')

View File

@ -2,8 +2,7 @@ import fs from "fs";
import path from 'path';
import sendPostMastodon, {
randomIntFromInterval,
findFirstImageInContent,
downloadImage,
getRandomElementOfArray,
findPictureAndSendPost
} from './utils.mjs'
@ -27,11 +26,6 @@ let reallySendPost = false;
// reallySendPost = true;
export function getRandomElementOfArray(listItems) {
return listItems[Math.floor(Math.random() * listItems.length)]
}
function getRandomLinkQzine() {
let filteredLinks = list_posts_json.filter(elem => elem.status === 'publish')
return getRandomElementOfArray(filteredLinks)

View File

@ -3,6 +3,7 @@ import path from 'path';
import {
randomIntFromInterval,
findPictureAndSendPost, getRandomLinkGeneral
} from './utils.mjs'
import Masto from "mastodon";
@ -15,7 +16,6 @@ let reallySendPost = false;
// reallySendPost = true;
function postLink() {
let postObject = getRandomLinkGeneral(tkpostsjson)

View File

@ -105,9 +105,9 @@ export default function sendPostMastodon(config) {
/**
* envoi avec fichier,
* on doit d'abord faire un upload du fichier,
* puis relier son id de media au nouveau post.
* puis relier son id de média au nouveau post.
*/
if (config.image) {
else if (config.image) {
var id;
console.log("envoi du média", config.image)
@ -223,6 +223,7 @@ function clearLink(linkString){
linkString = linkString.replace('http:', 'https:')
linkString = linkString.replace('https://www.ailesse.info/~tykayn/bazar/kotlife', 'https://www.tykayn.fr/wp-content/uploads/i/kotlife')
linkString = linkString.replace('https://blog.artlemoine.com/public/i', 'https://www.tykayn.fr/wp-content/uploads/i')
linkString = linkString.replace('https://www.ailesse.com/%7Etykayn/bazar', 'https://www.tykayn.fr/wp-content/uploads/i/bazar')
return linkString
}
@ -284,10 +285,6 @@ export function getRandomLinkGeneral(tkpostsjson) {
return getRandomElementOfArray(filteredLinks)
}
export function getRandomElementOfArray(listItems) {
return listItems[Math.floor(Math.random() * listItems.length)]
}
/**
* trouver l'image du contenu si il y en a