GithubHelp home page GithubHelp logo

ahmedelwerdany / blogger-image Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 315 KB

Upload photos to your blog for free and fast. No API, no hassle, just your photos and your blog ๐Ÿš€

Home Page: https://www.npmjs.com/package/blogger-image

License: MIT License

JavaScript 1.14% TypeScript 98.86%
blogger blogger-api image puppeteer upload upload-images

blogger-image's Introduction

blogger image

โฌ†๏ธ blogger-image helps you upload photos to blogger using simple api

install

npm i blogger-image
// or 
yarn add blogger-image

Usage

import Uploader from 'blogger-image'


const POST_ID = "https://www.blogger.com/blog/post/edit/.../...";

const uploader = new Uploader(
  POST_ID,
  {
    userDataDir: '/home/username/.config/chromium',
    // it is recommended to use an old version of chromium instead of the default browser.
    executablePath: '/home/username/.config/chrome-linux/chrome',  
  }
);
  
await uploader.init();

const result = await Promise.all([
  uploader.upload('./tree.png'),
]);

console.log(result);

// the `upload` method will not be available after this.
uploader.close();

kowen Issues

This package depends on puppeteer, which uses the latest version of Chromium.
The latest Chromium has problems with persistent login sessions, which may cause errors or unexpected behavior.
To avoid this, you need to use an old version on chromium and provide the "executablePath" option in your "new Uploader()" call, pointing to the path of the Chromium executable.

Follow the next instructions if you want to download an older version of Chromium and use it with the package.

Download an Old version of Chromium

cd ~/.config
wget "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F962947%2Fchrome-linux.zip?generation=1643115368404678&alt=media" -q  --show-progress -O chrome_2f962947.zip
unzip chrome_2f962947.zip

Login to Blogger

This will open the The version that we just downloaded.

cd chrome-linux; ./chrome
  • Go to blogger.com
  • Login
  • Close the browser
pwd

Copy the result becuase you're gonna need it in excutablePath.
It should be /home/{username}/.config/chrome-linux where {username} is your username.

Add it to the options.

const uploader = new Uploader(
  POST_ID,
  {
    userDataDir: '/home/username/.config/chromium',
    executablePath: '/home/username/.config/chrome-linux/chrome', // recomnded
  }
);

await uploader.init();

blogger-image's People

Contributors

ahmedelwerdany avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

thethao133

blogger-image's Issues

Language is not supported when it contains a โ€˜-โ€™ character

I've made a fresh install on a server and this time I've got Chromium in english and I see Blogger menu in english.
Anyway I have got this error:
" throw new Error('Sorry, language is not supported\nlanguage: ' + language);
^

Error: Sorry, language is not supported
language: en-GB
at Uploader.init (file:///home/cirillo-server/Desktop/OPENROBO/blogger-image/node_modules/blogger-image/build/index.js:64:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///home/cirillo-server/Desktop/OPENROBO/blogger-image/index.js:18:1
"

Can I help you in some way?
Thanks alot

Originally posted by @francescocassini in #1 (comment)

TimeoutError

I'm trying to use the code to upload very little image towards my blog.
Anyway I receive always this message:

node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:59
void this.terminate(new Errors_js_1.TimeoutError(Waiting failed: ${options.timeout}ms exceeded));
^
TimeoutError: Waiting for selector div[data-tooltip="Insert image"] failed: Waiting failed: 30000ms exceeded

Is it normal? I have to change waiting time? or data-tooltip is not more in the code of blogger?
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.