up composite de recommendations
This commit is contained in:
parent
9419acc0f5
commit
7ed103dba7
1984
assets/data/following_accounts.csv
Normal file
1984
assets/data/following_accounts.csv
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 318 KiB |
@ -9,15 +9,18 @@ import Masto from 'mastodon'
|
|||||||
* picture generation
|
* picture generation
|
||||||
*/
|
*/
|
||||||
import Jimp from 'jimp'
|
import Jimp from 'jimp'
|
||||||
import { getRequestOptions, sendGetRequest } from '../helpers/libs/utils.mjs'
|
import { getRequestOptions, randomIntFromInterval, sendGetRequest } from '../helpers/libs/utils.mjs'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
let reallySendPost = false
|
let reallySendPost = false
|
||||||
|
|
||||||
reallySendPost = true
|
reallySendPost = true
|
||||||
|
|
||||||
async function getFollowers (username, instance) {
|
async function getFollowers (username, instance) {
|
||||||
const url = `${instance}/api/v1/accounts/${username}/following`
|
const rand = randomIntFromInterval(1, 30) * 1000
|
||||||
|
console.log('random max id x 1000', rand)
|
||||||
|
const url = `${instance}/api/v1/accounts/${username}/following?max_id=${rand}000`
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(url)
|
const response = await axios.get(url)
|
||||||
@ -67,8 +70,9 @@ async function main () {
|
|||||||
|
|
||||||
const userIdOnInstance = '1'
|
const userIdOnInstance = '1'
|
||||||
|
|
||||||
const instance = 'mastodon.cipherbliss.com'
|
const instance = 'https://mastodon.cipherbliss.com'
|
||||||
|
|
||||||
|
// TODO get the followers from a csv file if there is one in assets/data/follows.csv
|
||||||
const followers = await getFollowers(userIdOnInstance, instance)
|
const followers = await getFollowers(userIdOnInstance, instance)
|
||||||
|
|
||||||
console.log('followers.length', followers.length)
|
console.log('followers.length', followers.length)
|
||||||
@ -82,12 +86,13 @@ async function main () {
|
|||||||
randomFollowers.forEach(account => {
|
randomFollowers.forEach(account => {
|
||||||
message += '\n' + displayDataAboutFollower(account)
|
message += '\n' + displayDataAboutFollower(account)
|
||||||
|
|
||||||
console.log('account', account)
|
console.log('account', account.acct)
|
||||||
|
|
||||||
avatars_urls.push(account.avatar_static)
|
avatars_urls.push(account.avatar_static)
|
||||||
})
|
})
|
||||||
message += '\n #fedifollows #curatorRecommendations'
|
message += '\n #fedifollows #curatorRecommendations'
|
||||||
|
|
||||||
generateAvatarComposite(avatars_urls)
|
await generateAvatarComposite(avatars_urls)
|
||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,10 +181,10 @@ function publishOnMastodon (folderUnpublished, configPost) {
|
|||||||
api_url: process.env.INSTANCE_MASTODON + '/api/v1/',
|
api_url: process.env.INSTANCE_MASTODON + '/api/v1/',
|
||||||
})
|
})
|
||||||
|
|
||||||
if (configPost.reallySendPost) {
|
let imagePath = `${path.resolve()}/${compositeFileName}`
|
||||||
|
console.log('------- imagePath', imagePath)
|
||||||
|
|
||||||
let imagePath = path.resolve() + configPost.image
|
if (configPost.reallySendPost) {
|
||||||
console.log('imagePath', imagePath)
|
|
||||||
/**
|
/**
|
||||||
* poster le média, puis faire un toot avec le média lié
|
* poster le média, puis faire un toot avec le média lié
|
||||||
*/
|
*/
|
||||||
@ -187,7 +192,8 @@ function publishOnMastodon (folderUnpublished, configPost) {
|
|||||||
.then(resp => {
|
.then(resp => {
|
||||||
let id = resp.data.id
|
let id = resp.data.id
|
||||||
configPost.media_ids = [id]
|
configPost.media_ids = [id]
|
||||||
console.log('\n\n id du média pour le post:', id)
|
console.log('\n\n id du média pour le post:', id, configPost)
|
||||||
|
|
||||||
masto.post('statuses', configPost).then(rep => {
|
masto.post('statuses', configPost).then(rep => {
|
||||||
// console.log('rep', rep)
|
// console.log('rep', rep)
|
||||||
console.log(`\n\n posté avec une nouvelle image, ${configPost.image} WOOT`)
|
console.log(`\n\n posté avec une nouvelle image, ${configPost.image} WOOT`)
|
||||||
@ -210,19 +216,27 @@ function publishOnMastodon (folderUnpublished, configPost) {
|
|||||||
main().then(message => {
|
main().then(message => {
|
||||||
// let md_message = convertHTMLtoMD(message)
|
// let md_message = convertHTMLtoMD(message)
|
||||||
let md_message = message.trim() + '\n'
|
let md_message = message.trim() + '\n'
|
||||||
|
console.log('message', message)
|
||||||
|
|
||||||
console.log('md_message', md_message)
|
console.log('md_message', md_message)
|
||||||
// upload de fileName et création du post par le Curator
|
// upload de fileName et création du post par le Curator
|
||||||
let configPost = {
|
let configPost = {
|
||||||
author: 'curator',
|
author: 'curator',
|
||||||
website: 'cipherbliss',
|
website: 'cipherbliss',
|
||||||
|
visibility: 'public',
|
||||||
|
language: 'fr',
|
||||||
|
sensitive: false,
|
||||||
postObject: {},
|
postObject: {},
|
||||||
folder_image: '.',
|
folder_image: '.',
|
||||||
image: compositeFileName,
|
scheduled_at: '',
|
||||||
|
scheduled_at_bool: false,
|
||||||
|
content_type: 'text/markdown',
|
||||||
|
// image: compositeFileName,
|
||||||
message: md_message,
|
message: md_message,
|
||||||
reallySendPost
|
reallySendPost
|
||||||
}
|
}
|
||||||
|
|
||||||
publishOnMastodon(folderUnpublished, configPost)
|
// publishOnMastodon(folderUnpublished, configPost)
|
||||||
|
|
||||||
}, err => {
|
}, err => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user