Giter Site home page Giter Site logo

m-kuzmin / ani-tui Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 0.0 131 KB

ani-cli in Rust with interactive TUI (Inactive)

Home Page: https://crates.io/crates/ani-tui

License: GNU General Public License v3.0

Rust 100.00%
ani-cli cli rust rust-lang tui anime

ani-tui's Introduction

AniTUI is a CLI (and in the future a TUI) app for searching and wathching anime in MPV. This is a Rust rewrite (quite literally a rewrite) of Pystardust's ani-cli. Thanks to ani-cli for decoding the magic of goload.pro or whatever mirror they have in the future.

Usage

AniTUI uses an ID in a format of <source:id>. To perform commands like watch or ep-count you need to first get an ID via search.

$ ani-tui search "keywords"

The output will contain a list of titles and IDs in <>. Copy the ID and use it in other commands.

$ ani-tui detail "<ID>"

$ ani-tui list-eps "<ID>"

detail will give you the most info about an anime like its description, ID, episode count and of course the title. list-eps only yields the title and number of episodes.

$ ani-tui watch "<ID>" 1

Watch an episode. Replace ID and 1 (episode number) with your values.

You can use either help command, -h or --help to get a help message explaining how to use AniTUI.


Contributing

  1. View open issues/projects or create your own issue
  2. Fork
  3. Write some code
  4. Refactor
  5. Write docs
  6. Make a pull request explaining the changes

Branch guide

main

A "checkpoint" of sorts. Contains the latest stable commit. Never commit to main, instead commit to `dev` and merge (PR not required).

dev

Contains the work in progress commits. Unlike main this can have failing tests and missing docs.

ani-tui's People

Contributors

m-kuzmin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ani-tui's Issues

Description not being captured by `easy_scraper` crate.

Describe the bug

For an anime like Kemono Jihen the description is plain text. In case of something like Pokemon XY the description has complex HTML in it.

Kemono Jihen

Kohachi Inugami, a detective who specializes in the occult, arrives at a remote village in the Japanese countryside ...

Pokemon XY

<p>
<span>The XY series is based on the events of the Generation VI games. As with the previous three series, the XY series begins with only&nbsp;
</span>
Satoshi
...

To Reproduce

  1. ani-tui detail "pokemon-xy"
    You will only see "Satoshi" and not the full description as on the website.

Expected behavior

The full description from the website. Formatting can be dropped.

Version info

  • ani-tui v0.1.1

This might be a wontfix

Reason: easy_scraper doesnt seem to have a good way to solve this and tbh goload.pro is the buggiest and most inconsistent website ever. So fixing might just not make sense. Help wanted: if someone has a fix that would be great.

TDD by Reso coder (Actually Uncle Bob)?

Problem

The code is hard to organize and its not very easy to maintain.

Solution

This app reminds me of TDD tutorial by Reso Coder, Episode 1 of that. Since a lot of the code is already in git I can try to start from scratch and do it this way. It will also enable extensions down the line.

Could Close #2.

Pros

Better flexibility in terms of user facing UI and ability to rewrite large chunks of impl. details without affecting the rest of the code (due to code structure).

Disadvantages

It may be an overkill and there could be some issue later that I don't know of.

Rewrite webpage parser

Problem

Parser struct became a Swiss knife of parsing webpages. And the returned data structures contain a lot of unnecessary fields

Solution

Each page would be loaded by the browser and put into its own page object that implements cached getters.

Example

//! pseudo code != current API

struct EpisodePage {
    html: String,
    title: Option<String>,
}

let anime = EpisodePage(browser.get("something")); // fast to create, doesnt process
let title = anime.title(); // parses on demand

Pros

It's essentially the same style as Parser, but takes the load off the parser since it already has so many pattern fields.

Disadvantages

This may impact the performance though. If each page compiles its own patterns it will not be as efficient as it could be.

  • Add pattern cache
  • (Optionally) What if there is need to parse different websites?

Fix goload.pro series identifiers

Expected behavior

An ID obtained from the search should be usable to get to other episodes in the series

Actual behavior

Some series have inconsistent links like:

goload.pro/videos/pokemon-xyz-episode-1
                  ~~~~~~~~~~~
goload.pro/videos/pokemon-xy-z-episode-30
                          ^^^^

So you cannot reach all episodes with the current ID format since it only incudes the ~~~ underlined part.

Solution

Make the ID store the episode link fully, and use the episode list on the page to navigate around. Proposed format:

<source:id#ep>
Where:

  • Source: a website name abbreviation followed by a version. E.g: <GLP-1:...>, -1 is a version number to make sure the new format can be distingueshed from the old format and an error is then detectable.
  • ID: The same as the ~~~ underlined part in the links above. <...:pokemon-xy-z#...>
  • Ep: Episode number at the end of the link. E.g: <...#12>

Example ID: <GLP-1:pokemon-xy-z#30>.

For commands that need an episode in the series like watch <id> <ep> the episode should still be supplied since changing the episode in the identifier could yield an invalid link.

Such link encoding cautions should also be applied to any other sources.

Version

0.1.1

std::Command in streaming link getter implementation?

Problem

AniTUI needs to go through some pretty weird hoops to get the streaming link. This could be implemented in rust by translating shell script to rust code, but there are two problems: (1) code could have to be updated, (2) this can be time consuming to rewrite and write for the first time.

Solution idea

So to make updating this critical part of the code faster I propose to just write it using a rather safe std::Command API.

Example

// pseudo rust
let v = some_rust_code();
more_rust_code(Command::execute().arg(v).get_stdout());

Pros

  1. It's fast to update
  2. It's still possible to rewrite anytime in pure rust with no Command invocations. And both solutions are very compatible.

Disadvantages

Its not as rusty as it could be. And maybe its slower. However from my experience the most amount of time is spent while MPV is downloading content anyway.

And (no benches so no proof) but this shouldn't be that time consuming to execute.

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.