aniping.front_end

front_end

This submodule handles functions required by the front_end - app.py. Most functions should be defined here and called by app.py. Because app.py will only call to this particular submodule, it is acceptable to include functions that do nothing but call back to a different function in the module.

class aniping.front_end.FrontEnd(config, plugin_manager=None)

Front End plugin for Aniping.

This is a “special” plugin this is called directly from the main server thread, and not handled by the plugin manager. This handles all front-end services the application may need, and calls back to other plugins as necessary.

add_update_show(dbid, beid, subgroup)

Adds a given show to the backend, or edits it if its already there.

Calls db.change_show to update the database with the backend id.

Parameters:
  • dbid (int) – The database ID for the show.
  • beid (int) – The backend ID for the show.
  • subgroup (str) – The selected subgroup for the show, from our search engine.
check_auth(username, password)

Authentication Check Function.

Checks if a user gives a correct username and password. User and pass are checked back against our backend, we do not handle our own authentication.

Parameters:
  • username (str) – The username to check.
  • password (str) – The password to check.
Returns:

bool.

  • True – user is authenticated
  • False – user is not authenticated or an error occurred

check_login_id(session_id)

Session ID Check Function.

Gets a session id from the database and checks that it’s valid. If no session id is passed or if it’s invalid, check if the backend has logins enabled.

Parameters:session_id (str) – The session ID for the user.
Returns:bool.
  • True – Session id is valid or back end logins are disabled.
  • False – Session id is not valid or has expired.
delete_login_id(session_id)

Session id Delete Function.

Deletes a session id from the database. Used for logging out. Just calls back to db.delete_login_id.

Parameters:session_id (str) – The session ID for the user.
do_first_time_setup()

Begins first time setup for aniping. Starts a new thread to scrape shows.

Returns:bool. Always returns true.
get_all_subgroups()

Gets the subgroups for all shows from the search engine.

This should be done asynchronously after scraping all shows, to allow for a quick and easy subgroup selection when trying to find a show.

get_fanart(beid)

Gets some fanart for the show from the backend.

Calls back to back_end.fanart, but because that should be a list, just get the first item from that list.

Parameters:beid (int) – the backend ID for the show.
Returns:str. A link to some fanart.
get_selected_group(beid)

Gets the selected subgroup for the show from the backend.

Just calls back to back_end.subgroup_selected.

Parameters:beid (int) – the backend ID for the show.
Returns:str. The subgroup selected for the series.
get_show_from_backend(beid)

Gets a known show from the backend system from its id.

Parameters:beid (int) – the backend ID for the show.
Returns:dict. The backend show information.
get_show_from_db(dbid=None)

Gets the show information out of the database.

Just calls back to db.get_show.

Parameters:dbid (int) – the database ID for the show.
Returns:dict. The show information for the ID passed.
get_shows_for_display(term=None)

Gets shows from the scraper and preps them for display.

If a term is provided, only get shows that include that term.

Keyword Arguments:
 term (str) – A search term to filter on.
Returns:tuple. 4 lists of shows.
  • watching – Shows currently being watched.
  • airing – TV shows being aired.
  • specials – TV and Web Specials (OVA, ONA, etc.) airing or due to air.
  • movies – Movies airing or due to premiere.
get_subgroups(dbid, show=None)

Gets a list of sub groups from the search engine.

Generally this will be a torrent search site, like nyaa. Nothing is ever downloaded directly with aniping! The backend should handle that, if downloading is happening. This only gets a list of groups subtitling the show.

Parameters:dbid (int) – the database ID for the show.
Returns:list. A list of subgroups.
output_display_lists(watching, airing, specials, movies)

Takes the display lists and massages them for output.

It does this by removing watching shows from the other lists, handling date formats, and similar tasks.

Parameters:
  • watching (list) – A list of shows currently being watched.
  • airing (list) – A list of TV shows currently airing.
  • specials (list) – A list of TV and web Specials airing or due to air this season.
  • movies (list) – A list of Movies airing or due to premiere this season.
Returns:

tuple. 4 lists of shows.

  • watching – Shows currently being watched.
  • airing – TV shows being aired.
  • specials – TV and Web Specials (OVA, ONA, etc.) airing or due to air.
  • movies – Movies airing or due to premiere.

remove_show(dbid)

Removes a show from the backend given it’s database ID

Parameters:dbid (int) – The database ID for the show.
scrape_shows()

Calls to the scraper to scrape shows and add them to the database.

Creates a lockfile in /tmp to ensure multiple scraping threads don’t run simultaneously.

Returns:bool.
  • True – Scrape is complete.
  • False – Scrape lock file exists.
search_show_from_backend(dbid)

Gets a show from the database and searches for it in the backend system.

Parameters:dbid (int) – the database ID for the show.
Returns:dict. The backend search results for the id passed. None if not found.
set_login_id()

Session id Creator

Creates a session id and writes it to the database.

Returns:str. The id of the session.
star_show(dbid)

Show starring/highlighting function.

Toggles a show starred status in the database.

Parameters:dbid (int) – The database ID of the show to star.