Git Product home page Git Product logo

sopel-anitv's Introduction

sopel-AniTV

AniTV module for sopel to get showtimes and channels from the AniTV API.

Requirements

The AniTV module relies on the following Python modules:

  • datetime (standard Python library)
  • re (standard Python library)
  • requests (should be in standard Python library)

Configuration

The AniTV module requires configuration before it will function. The required configuration consists of:

  • The AniTV server to use
    • (optional) The API key needed to connect to the AniTV server, if required by the server

Known servers

Known active servers as of September 2017:

(A default, public server was included with this module previously, but it shut down in October 2016.)

Usage

Commands & arguments:

  • .ani <search keywords> -r -3 -ch BS11
    • <search keywords>: the title (or keyword) to search on AniTV
    • -1 to -5: specify how many results to retrieve (5 is the hardcoded maximum)
    • -r: reverse sort order (has no effect if the default of one result is returned)
    • -ch channelname or -st station: filter results by station/channel name (must not contain spaces)

Arguments can be specified in any order, with the caveat that required parameters (currently only -ch/-st has this) may not be separated from their argument. For example, the command .ani imouto -ch -3 BS11 would not work as expected; it would search for the keywords "imouto BS11" filtered by channel name "-3", and probably return no results.

sopel-anitv's People

Contributors

dgw avatar spanishharlem avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

sopel-anitv's Issues

Support defining a list of nicknamed servers

The idea would be to use server nicknames in a -srv or similar argument.

Not sure how practical this is to implement any more, now that the foolz instance is dead and I haven't found any other instances save for @Yuuki2012's…but I did have this idea, and it can always be WONTFIX'd.

Bot-name Easter egg

If someone does .ani botnick the bot should return an Easter egg response, maybe like botnick episode <randint> is currently airing on <#currentchannel or botnickTV>

Foolz' AniTV server is probably dead

Currently, anitv.foolz.us is refusing connections. I'm not sure when it started doing so, but if it is gone permanently then it can't be the default server any more.

Support spaces in channel/station name

Would be nice to be able to filter on e.g. -ch Tokyo MX. Maybe only support spaces when the argument is specified using = and quotes?

This looks like it'll be an annoying regex problem at best, and a mild nightmare to code at worst.

Use a real argument parser

I've been avoiding work on #5 and #8 (and anything else related to arg parsing) for ages because it's just so annoying to deal in regex. So I'm making a decision: This module should use a real argument parser.

Since argparse is included in Python's standard library, that's probably the way to go. It looks like splitting the input into a list of strings and passing it to the parser will work (according to docs.python.org), and as long as parsing arbitrary argument lists is possible (since sys.argv is irrelevant to this application), everything else is just a matter of reading the docs.

Add ability to specify episode number to find

Probably using -ep [0-9]+ argument.

Best to investigate how the AniTV API returns episode numbers and make sure to use the right data type (int/string) and zero-padding (not sure if the API uses it).

6.x compatibility

Needs to import from sopel instead of willie to be compatible with the 6.x bot framework release/name change. Ideally should try to import from willie if importing from sopel fails, to maintain backward compatibility for the time being.

Changing API server at runtime

There's no particular reason that the API server address shouldn't be configurable at runtime; it just isn't currently supported because of how the config value is loaded.

Actually, there might be a new Sopel API feature in here… Modules could use a way to register a handler function to be run whenever certain config values change. I'll think on that.

Switchable server

Would be nice to have the ability to configure which server to use, since the default specified in the current code has some issues that other people have fixed in their own instances.

Should retain current default, work even if no settings configured, and support private instances that require API keys.

Properly require spaces between arguments

The changes that caused #7 had to be nerfed because they were too good at finding spaces. But spaces should still be required between arguments.

Broken arg-parsing resulted from the code parsing an argument out of the middle and then also removing the spaces on both sides of it, so subsequent matches would usually fail because of the use of \s+. What's needed is enforcing the spaces (or line start/end) in order to match an argument, but making sure to leave one space when the parsed argument is removed from the input. (This may necessitate trim()'ing the search string before calling the AniTV API.)

Alternatively? Don't remove the args from the input as they're parsed. That could be a way toward better predictability.

I guess the real solution would be to actually parse the arguments (say, by tokenization), but whether implemented from scratch or imported from an existing library, that's a lot of effort and maybe even another dependency that shouldn't really be added.

Error when filtering by channel if a result has no station defined

<Ryuunosuke> ani youjo senki -ch BS11
<Kaede> AttributeError: 'NoneType' object has no attribute 'lower' (file
        "/var/lib/sopel/modules/anitv.py", line 91, in anitv)

Line 91 is where this part of the lookup routine happens:

        if args['chan']:
            if args['chan'].lower() not in result['station'].lower():
                continue

Obviously args['chan'] is not NoneType because the first condition is met. Therefore, it must be result['station'] that is throwing the error. In fact, format_result() handles unknown stations, so the search portion of the code must do so also (it runs before the results are formatted, naturally).

Replace "Unknown station" with actual station name

Apparently "I think something messed up when you tried to copy that." is caused by the station name containing an & character. So says @Yuuki2012.

Calling this an enhancement, because it's not actually a bug in the module but a bug in AniTV itself.

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.