Giter Site home page Giter Site logo

anitopy's Introduction

Anitopy

Anitopy is a Python library for parsing anime video filenames. It's simple to use and it's based on the C++ library Anitomy.

Example

The following filename...

[TaigaSubs]_Toradora!_(2008)_-_01v2_-_Tiger_and_Dragon_[1280x720_H.264_FLAC][1234ABCD].mkv

...can be parsed using the following code:

>>> import anitopy
>>> anitopy.parse('[TaigaSubs]_Toradora!_(2008)_-_01v2_-_Tiger_and_Dragon_[1280x720_H.264_FLAC][1234ABCD].mkv')
{
    'anime_title': 'Toradora!',
    'anime_year': '2008',
    'audio_term': 'FLAC',
    'episode_number': '01',
    'episode_title': 'Tiger and Dragon',
    'file_checksum': '1234ABCD',
    'file_extension': 'mkv',
    'file_name': '[TaigaSubs]_Toradora!_(2008)_-_01v2_-_Tiger_and_Dragon_[1280x720_H.264_FLAC][1234ABCD].mkv',
    'release_group': 'TaigaSubs',
    'release_version': '2',
    'video_resolution': '1280x720',
    'video_term': 'H.264'
}

The parse function receives a string and returns a dictionary containing all found elements. It can also receive parsing options, this will be explained below.

Installation

To install Anitopy, simply use pip:

pip install anitopy

Or download the source code and inside the source code's folder run:

python setup.py install

Options

The parse function can receive the options parameter. E.g.:

>>> import anitopy
>>> anitopy_options = {'allowed_delimiters': ' '}
>>> anitopy.parse('DRAMAtical Murder Episode 1 - Data_01_Login', options=anitopy_options)
{
    'anime_title': 'DRAMAtical Murder',
    'episode_number': '1',
    'episode_title': 'Data_01_Login',
    'file_name': 'DRAMAtical Murder Episode 1 - Data_01_Login'
}

If the default options had been used, the parser would have considered _ as a delimiter and replaced it with space in the episode title.

The options contain the following attributes:

Attribute name Type Description Default value
allowed_delimiters string The list of character to be considered as delimiters. ' _.&+,|'
ignored_strings list of strings A list of strings to be removed from the filename during parse. []
parse_episode_number boolean If the episode number should be parsed. True
parse_episode_title boolean If the episode title should be parsed. True
parse_file_extension boolean If the file extension should be parsed. True
parse_release_group boolean If the release group should be parsed. True

anitopy's People

Contributors

euklios avatar igorcmoura avatar kayabe avatar mdcx avatar mnabid avatar tylergibbs2 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

anitopy's Issues

Anitopy throws `KeyError` when parsing filename

When there's a filename in the following format —

ANIME_TITLE   Season X   ANIME_TYPE   [round, square or curly brackets]   EXACT_SAME_ANIME_TYPE   Episode Y

anitopy fails to parse it and throws an exception.

It only triggers when the same anime_type is repeated once or more and there's something (or nothing) in brackets between them. The error doesn't happen when I omit the season or episode number.

Example

>>> anitopy.parse("One-Punch Man Season 1 OVA [Judas] OVA - 05.mkv")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/anitopy/anitopy.py", line 48, in parse
    if not parser.parse():
  File "/usr/lib/python3.9/site-packages/anitopy/parser.py", line 33, in parse
    self.validate_elements()
  File "/usr/lib/python3.9/site-packages/anitopy/parser.py", line 302, in validate_elements
    Elements.erase(ElementCategory.EPISODE_TITLE)
  File "/usr/lib/python3.9/site-packages/anitopy/element.py", line 107, in erase
    del cls.instance()._elements[category.value]
KeyError: 'episode_title'

[BUG] Cannot parse title of 4k resource, miss video_resolution property

>>> anitopy.parse('[GM-Team][国漫][诛仙][Jade Dynasty][2022][11][HEVC][GB][1080p]')
{'file_name': '[GM-Team][国漫][诛仙][Jade Dynasty][2022][11][HEVC][GB][1080p]', 'video_resolution': '1080p', 'video_term': 'HEVC', 'anime_year': '2022', 'episode_number': '11', 'anime_title': 'Jade Dynasty', 'release_group': 'GM-Team'}
>>> anitopy.parse('[GM-Team][国漫][诛仙][Jade Dynasty][2022][11][HEVC][GB][4K]')
{'file_name': '[GM-Team][国漫][诛仙][Jade Dynasty][2022][11][HEVC][GB][4K]', 'video_term': 'HEVC', 'anime_year': '2022', 'episode_number': '11', 'anime_title': 'Jade Dynasty', 'release_group': 'GM-Team'}

Missing video_resolution property

Extend the recognition algorithm (regex)

Extend the recognition algorithm. Since A lot fansub having this version scheme. Probably if you want to add it as well.

Not work:
 - [Judas] Chuunibyou S1 - NCEDv2.mkv # season 1 ending
 - File: [Judas] Chuunibyou S1 - S02.mkv  # season 1 special eps 2
 - File: [Judas] Clannad - S01OVA01.mkv  # season 1 ova eps 1
Work:
 - [Judas] Chuunibyou S1 - NCED v2.mkv
 - [Judas] Chuunibyou S1 - SP02.mkv
 - [Judas] Clannad - S01 OVA01.mkv

If you would add this, I can search for the files using those scheme.
For now, i just add the check on mine manually before be parsed by anitopy.

Plans for Episode Season Detection?

I was wondering if you have any plans to add seasonal information in titles? e.g:

[HorribleSubs] Mob Psycho 100 S2 - 07 [1080p].mkv

Thank you for this neat and handy tool, really saved me from a lot of headaches

Fix release_group detection for scene naming

The release group isn't properly parsed from some files that use scene naming.

Example:
{'file_name': 'JoJos.Bizarre.Adventure.2012.S02E47.Dios.World.3.1080p.BluRay.Remux.DTS-HD.MA2.1.H.264-Meakes.mkv', 'file_extension': 'mkv', 'video_term': 'H.264', 'video_resolution': '1080p', 'source': 'BluRay', 'release_information': 'Remux', 'anime_season': '02', 'episode_number': '47', 'anime_title': 'JoJos Bizarre Adventure 2012', 'episode_title': 'Dios World.3'}

This naming style has most of the information delimited by ., but the release group delimited at the very end by a dash. Ideally, anitopy would correctly return 'release_group':'Meakes'.

Stop using singletons

Currently the Elements and Tokens classes are singletons. The problem is that we have to be very careful to clean everything between each parse or else state from a previous parse may remain in future parses.

It would be much better if a new instance was created at every parse to ensure total isolation.

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.