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
|
||||
*/
|
||||
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 path from 'path'
|
||||
|
||||
let reallySendPost = false
|
||||
|
||||
reallySendPost = true
|
||||
|
||||
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 {
|
||||
const response = await axios.get(url)
|
||||
@ -67,8 +70,9 @@ async function main () {
|
||||
|
||||
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)
|
||||
|
||||
console.log('followers.length', followers.length)
|
||||
@ -82,12 +86,13 @@ async function main () {
|
||||
randomFollowers.forEach(account => {
|
||||
message += '\n' + displayDataAboutFollower(account)
|
||||
|
||||
console.log('account', account)
|
||||
console.log('account', account.acct)
|
||||
|
||||
avatars_urls.push(account.avatar_static)
|
||||
})
|
||||
message += '\n #fedifollows #curatorRecommendations'
|
||||
|
||||
generateAvatarComposite(avatars_urls)
|
||||
await generateAvatarComposite(avatars_urls)
|
||||
return message
|
||||
}
|
||||
|
||||
@ -176,10 +181,10 @@ function publishOnMastodon (folderUnpublished, configPost) {
|
||||
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
|
||||
console.log('imagePath', imagePath)
|
||||
if (configPost.reallySendPost) {
|
||||
/**
|
||||
* poster le média, puis faire un toot avec le média lié
|
||||
*/
|
||||
@ -187,7 +192,8 @@ function publishOnMastodon (folderUnpublished, configPost) {
|
||||
.then(resp => {
|
||||
let id = resp.data.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 => {
|
||||
// console.log('rep', rep)
|
||||
console.log(`\n\n posté avec une nouvelle image, ${configPost.image} WOOT`)
|
||||
@ -210,19 +216,27 @@ function publishOnMastodon (folderUnpublished, configPost) {
|
||||
main().then(message => {
|
||||
// let md_message = convertHTMLtoMD(message)
|
||||
let md_message = message.trim() + '\n'
|
||||
console.log('message', message)
|
||||
|
||||
console.log('md_message', md_message)
|
||||
// upload de fileName et création du post par le Curator
|
||||
let configPost = {
|
||||
author: 'curator',
|
||||
website: 'cipherbliss',
|
||||
visibility: 'public',
|
||||
language: 'fr',
|
||||
sensitive: false,
|
||||
postObject: {},
|
||||
folder_image: '.',
|
||||
image: compositeFileName,
|
||||
scheduled_at: '',
|
||||
scheduled_at_bool: false,
|
||||
content_type: 'text/markdown',
|
||||
// image: compositeFileName,
|
||||
message: md_message,
|
||||
reallySendPost
|
||||
}
|
||||
|
||||
publishOnMastodon(folderUnpublished, configPost)
|
||||
// publishOnMastodon(folderUnpublished, configPost)
|
||||
|
||||
}, err => {
|
||||
console.error(err)
|
||||
|
Loading…
Reference in New Issue
Block a user