Git Product home page Git Product logo

pixiv.ts's Introduction

Hello, I am a web developer mostly working with Typescript.

My Apps:
Music Player, a music player with reversing, time stretching, and pitch shifting effects.
Photo Viewer, a photo viewer with resizing and color correction effects.
Video Player, a video player with reversing and time stretching effects.
Waifu2x GUI, an image, gif, and video upscaler.
Image Compressor, an image and gif compressor.

My Websites:
Kisaragi Website, the website of my discord bot.
Cuteanime, an interface to watch anime with japanese subtitles.
Cutemanga, an interface to read manga with japanese ocr'd text.
Moebooru, an image board website organized by tags.
Local Image Viewer, an interface to view local images.

Misc:
Kisaragi Bot, a discord bot having 300+ commands.

pixiv.ts's People

Contributors

chinhongtan avatar dependabot[bot] avatar diamond-frost avatar rayriffy avatar sotrx avatar tenpi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pixiv.ts's Issues

util.multiCall seems to be not working

I'm not very sure if I am using it wrongly, here's my code snippet:

const pixiv = await Pixiv.default.refreshLogin(refreshToken);
const word = 'ロリ';
let illusts = await pixiv.search.illusts({ word: word, r18: false, type:'illust', bookmarks: '1000' });
if (pixiv.search.nextURL) illusts = [...illusts, ...await pixiv.util.multiCall({ next_url: pixiv.search.nextURL, illusts }, 2)];

I noticed that no matter what number I use for limit (which is 2 in the code above), it always ends up returning Error: Request failed with status code 400. If no limit is provided, it will end up returning Error: Request failed with status code 403.

Also, using await Pixiv.refreshLogin(refreshToken) like the example in the readme.md will not work. An error will pop up saying TypeError: Pixiv.refreshLogin is not a function. It took me quite a while to figure out that I have to use Pixiv.default.refreshLogin instead.

reopen. client.util.downloadIllust does not wait

I am reopening this issue because the previous one was closed but the issue is still there.

Here is what i came up with to 'solve' the issue

const img_dir = "./downloaded";
await client.util.downloadIllust(url, img_dir, "original");

// should be downloaded by now
let exit = false;
let prev_hash = "";
let images: string[] = [];
while(true) {
    let images_stats = fs.readdirSync(img_dir);
    let curr_hash = "";
    images = [];
    for (const image_stats of images_stats) {
        const file = img_dir + "/" + image_stats;
        images.push(file);
        curr_hash += await getFileHash(file);
    }
    if(exit) {
        break;
    }
    if (prev_hash != curr_hash || !curr_hash.length) {
        debug(`hash mismatch, waiting... (${prev_hash} || ${curr_hash})`);
    }
    exit = prev_hash == curr_hash && curr_hash.length > 0;
    prev_hash = curr_hash;
    await sleep(1000);
}

// by this point the images are downloaded, but the solution is mega-crap

here is the output

hash mismatch, waiting... (c397c6d991c6ddc033cc089b33a412355 || af1349b9f5f9a1a6a0404dea36dcc9499)
hash mismatch, waiting... (af1349b9f5f9a1a6a0404dea36dcc9497 || efb763f51eb0780232d81f86cdc86135c)
hash mismatch, waiting... (a2344fc328fe26a3ff5f241c10ba91071 || 9183ef0552ac039c012bec3885eb85d79)
hash mismatch, waiting... (2b90f3912a26806e03a96f0a107870f16 || 015537fcb4eee269792ed88ad1d7bdb84)
hash mismatch, waiting... (b90f3912a26806e03a96f0a107870f167 || 12a26806e03a96f0a107870f167258f9a)

as you can see, the hash changes which means that the files are still downloading, please don't close this issue blaming me, this is clearly a problem in the library

Log in with cookies?

Can I log in with cookies (PHPSESSID) that I could get from pixiv page?

I tried using Pixiv.refreshLogin() with my cookies as the parameter and it doesn't work.
Can we improve this method to support login with cookies too?

login invalid_grant error

Tried to login but I get an error:
image

Relevant code:

import Pixiv from 'pixiv.ts';
import { env } from './environment';

let client: Pixiv;

export async function usePixivClient() {
  if (!client) {
    client = await Pixiv.login(env.pixiv.username, env.pixiv.password);
  }

  async function getUserIllustrations(params: Parameters<typeof client['user']['illusts']>[0]) {
    return await client.user.illusts(params);
  }

  return {
    getUserIllustrations,
  };
}

Third time's the charm. await client.util.downloadIllust does not wait

I literally just took your example with the hashes and it doesn't work.

await client.util.downloadIllust(url, "./downloads", "original");

const files = fs.readdirSync(path.join(__dirname, "../downloads")).map((p) => {
    return path.join(__dirname, "../downloads", p)
})
const hash = crypto.createHash("md5").update(fs.readFileSync(files[0])).digest("hex")
console.log(hash);
for(let i = 1; i < 5; i++) {
    setTimeout(() => {
        const hash2 = crypto.createHash("md5").update(fs.readFileSync(files[0])).digest("hex")
        console.log(hash2)
        console.log(hash === hash2)
    }, i * 1000)
}

the output is as follows

2a96de86c25cd98a85c89debfed3fe4e
7cbe45c3c4fdf5cf4c3cd0ae78ee1a1b -- after a second
false
aad8d30495ccc35463511dc27bd0e52d -- after 2 seconds
false
f56fb56448ec3df54eb0986a81ce0554 -- after 3 seconds
false
4528e847c998aa0617f56412ca11a624 -- after 4 seconds
false
25cd98a8aaaad7f56412e4e2a96de86c -- after 5 seconds
false

and also, i get this

please dont close the damn issue, let's discuss this, I just don't see where this is my problem

here is the post I tried it on: https://www.pixiv.net/en/artworks/98079929

It contains 3 images by the way

await util.downloadIllust does not work

Basically I want to download images to a folder and after they are downloaded, convert and move them to another folder.

This does not work and crashed with [Error: VipsJpeg: Premature end of input file] because files didn't finish downloading yet

const illust = await client.illust.get(url);
const img_dir = "./downloaded";
await sendToChannel(channel, `📥 Downloading from pixiv`);
await client.util.downloadIllust(illust, img_dir, "original");

let images = walk(img_dir);

for (const image of images) {
    const new_file_name = getFileName(image);
    const new_file_path = await getFilePath(new_file_name, channel);
    if(new_file_path) {
    await processAndSaveImage(fs.createReadStream(image));
    fs.unlinkSync(image);
}

However, if i add sleep(5000); before walk(img_dir); it works, which means that await client.util.downloadIllust(illust, img_dir, "original"); does not actually wait untill all images are saved

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.