anigo-org / anigo-cli

A console tool to search and watch anime.
Apache License 2.0
10 stars 1 forks source link

Windows Support? Problems and temporary solutions. #5

Open bachig26 opened 1 year ago

FlamesX-128 commented 1 year ago

Currently Go plugins are only supported on Linux, FreeBSD, and macOS. :cry:

https://pkg.go.dev/plugin

FlamesX-128 commented 1 year ago

@bachig26 I made a small version with integrated consumet, I tried it slightly with wine

anigo@integrated-win@amd64.zip

bachig26 commented 1 year ago

@FlamesX-128 it worked for me, but there are some issues like:

  1. when I tried it without manually downloading plugins, it installs both plugin but only showing gogoanime. also after it said that the plugins are installed...there is no files in the folder.

  2. when downloaded the plugins manually, it still says that it needs to download as there is no plugins.

    λ anigo
    ? No plugins found, do you want to install some? Yes
    [Plugin] [Installing] monochinos@1.0.1-v1.0.0-linux-amd64
    [Plugin] [Installing] consumet@1.0.1-v1.0.0-linux-amd64
    ? Select an option Search
    ? Select a provider  [Use arrows to move, type to filter]
    > [API] [Direct] GoGoAnime

as you can see only GoGoAnime is showing as a provider, even after the Installing plugins shows both.

  1. when I exit the program, it displays an error:
    
    ? Select an option Exit
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal 0xc0000005 code=0x0 addr=0x0 pc=0xaa5739]

goroutine 1 [running]: main.main() /home/flames/go/github.com/FlamesX-128/anigo/main.go:50 +0x119

bachig26 commented 1 year ago

@FlamesX-128

I changed the directory: C:\anigo\anigo\plugins, also reverted the anigo filename to original name as anigo@integrated-win@amd64.

image

λ anigo@integrated-win@amd64
? Select an option Search
? Select a provider  [Use arrows to move, type to filter]
> [API] [Direct] GoGoAnime

still I can't see all the available plugins and has the same exit error.

I want to ask if the Exit or Back option provided at the each line if possible.

FlamesX-128 commented 1 year ago

@bachig26 1- I will check the plugin system later, in theory it should not show any that are not from your system:

2- It lets you watch the anime but when you leave it gives an error or it give an error before you can watch the anime?

FlamesX-128 commented 1 year ago

@bachig26 Go's plugin system doesn't work on windows, so just integrate consumet directly into the program, it won't download anything.

import (
    // <...>
    "github.com/FlamesX-128/anigo-plugins/consumet/gogoanime"
)

func init() {
    // <...>
    providers["[Api] [Direct] GoGoAnime "] = gogoanime.PackageModel{}
}
bachig26 commented 1 year ago

2- It lets you watch the anime but when you leave it gives an error or it give an error before you can watch the anime?

it lets me watch anime, but it didn't give me the error when I leave it or before it...the error only shows when select the Exit option.

Example:

λ anigo@integrated-win@amd64
? Select an option Search
? Select a provider [API] [Direct] GoGoAnime
? what novel do you want to look for? naruto

? what novel do you want to look for? naruto
? which novel do you want to select? Naruto Shippuden
? which do you want to select? watch
? which episode do you want to select? (1-500) 1

? which episode do you want to select? (1-500) 1
? which quality do you want to select? 360p
? Select an option Exit
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xcf5739]

goroutine 1 [running]:
main.main()
        /home/flames/go/github.com/FlamesX-128/anigo/main.go:50 +0x119
FlamesX-128 commented 1 year ago

@bachig26 I think it's how os.Exit() works, which is used to kill the program.

image

bachig26 commented 1 year ago

@bachig26 Go's plugin system doesn't work on windows, so just integrate consumet directly into the program, it won't download anything.

import (
    // <...>
    "github.com/FlamesX-128/anigo-plugins/consumet/gogoanime"
)

func init() {
    // <...>
    providers["[Api] [Direct] GoGoAnime "] = gogoanime.PackageModel{}
}

sorry, but I can't clearly understand this... as far I can get that the consumet iintegrated already.

if that's the case, then it should not ask for installing the plugins while running the anigo, right?

FlamesX-128 commented 1 year ago

@bachig26

By default it is not installed, when the program asks you if you want to install it should download a ".so" or ".dylib" file.

These are saved in anigo/plugins where they will be loaded every time it is turned on.

In the case of windows, it uses ".dll", it is not supported by the Go library, the temporary solution I did was directly add it to the program.

Original code:

func init() {
    var root string
    var err error

    if root, err = os.Getwd(); err != nil {
        log.Panicln(color.RedString("[Plugin] [Init] [Error] %s", err.Error()))

        return
    }

    // Load plugins.
    for _, plugin := range plugins.Init[models.Plugin](root, "Plugin") {
        // Register provider.
        for name, provider := range plugin.Providers {
            providers[name] = provider
        }

    }

}

Temporary solution for windows.

func init() {
    var root string
    var err error

    if root, err = os.Getwd(); err != nil {
        log.Panicln(color.RedString("[Plugin] [Init] [Error] %s", err.Error()))

        return
    }

    // Load plugins.
    // Won't install plugins.
    for _, plugin := range plugins.Init[models.Plugin](root, "Plugin") {
        // Register provider.
        for name, provider := range plugin.Providers {
            providers[name] = provider
        }

    }

       // compile "anigo-plugins/consumet/gogoanime" with the core.
       providers["[Api] [Direct] GoGoAnime "] = gogoanime.PackageModel{}
}
FlamesX-128 commented 1 year ago

I was going to integrate monoschinos too but because I put the code in a "main" package instead of a "monochinos" package I couldn't add it. :cry:

FlamesX-128 commented 1 year ago

anigo@integrated-win@amd64.zip [Español|Spanish] monochinos2 added.

bachig26 commented 1 year ago

anigo@integrated-win@amd64.zip monochinos2 added.

thank you, i'll try it out 👍

FlamesX-128 commented 1 year ago

[Rewrite to Rust] I'm working on compatibility and improving the plugin manager, it may take me a few days to finish it. So sorry for taking so long.

bachig26 commented 1 year ago

[Rewrite to Rust] I'm working on compatibility and improving the plugin manager, it may take me a few days to finish it. So sorry for taking so long.

no worries. 🍀