# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['namer']

package_data = \
{'': ['*']}

install_requires = \
['lxml>=4.8.0,<5.0.0',
 'mutagen>=1.45.1,<2.0.0',
 'pathvalidate>=2.5.0,<3.0.0',
 'rapidfuzz>=2.0.5,<3.0.0',
 'requests>=2.27.1,<3.0.0',
 'schedule>=1.1.0,<2.0.0',
 'watchdog>=2.1.6,<3.0.0']

setup_kwargs = {
    'name': 'namer',
    'version': '0.5.0',
    'description': 'A namer of video files based on metadata from the porndb.',
    'long_description': 'Namer\n#########\n\n.. image:: https://github.com/4c0d3r/namer/actions/workflows/ci.yml/badge.svg?\n  :target: https://github.com/4c0d3r/namer/actions/workflows/ci.yml/\n.. image:: https://codecov.io/gh/4c0d3r/namer/branch/main/graph/badge.svg?token=4MQEN2NUKZ\n  :target: https://codecov.io/gh/4c0d3r/namer\n.. image:: https://badge.fury.io/py/namer.svg?\n  :target: https://badge.fury.io/py/namer  \n\nNamer is a powerful command line tool for renaming and tagging mp4 video files in a way that helps plex/jellyfin/emby and related plugins extract that data or lookup data with the PornDB_\'s plugins for plex or jellyfin/emby.\n\nWhy should I use this?\n----------------------\n\n1.  You have partially well structured file names (say from an rss feed, etc) and you never want to have to manually match files in plex/jellyfin/emby with the PornDB_\'s plugin.\n2.  You don\'t want your recent videos to be added to your library until they are matchable in the PornDB_.\n3.  You want to store the metadata about a file in mp4 files, in a way that can be read by Apple TV app, including information like: Studio, date created, name, performers, original url, proper HD tags, ratings, and movie poster.   All of this data is readable by Plex, and most by Jellyfin/Emby in case you want to standard Apple video players or your library\'s metadata storage is ever damaged.\n\nHow successful at matching videos is this tool?\n------------------------------------------------\n\nFor data pulled from the intered with rss feeds (which are often in the file format listed below) .... perfect.  The author and others have only experienced one mismatch, and that type of failure can never occur again.   \n\nIf running in a background watchdog mode, files that were failed to match are retried every 24 hours, letting the PornDB_ scrapers catch up with any metadata they may be missing.\n\nOptionally, a log file can be enabled to show the original file name parts, what options were evaluated, and which match was used to name the file, it will be written next to your video file with the same name as the file (with a _namer.log) suffix rather than an mp4/mkv extension.   This is very useful for sanity checking matches, and if ever a mismatch does occur the original file name is available in the log.\n\n\nFor the curious, how is a match made?\n------------------------------------------------\n\nIt assumes that file names exist as in a format like ```sitename-[YY]YY-MM-DD-Scene.and.or.performer.name.mp4.```.  A power regex tries to determine the various parts of a file\'s name.   Note that the seperating dashes and dots above are interchangable, and spaces may also be used as seperators (or any number of any combo of the three.) \n\nWhen determining a possible queried match from the PornDB_:\n\nSitename my not need be the full name of the site, as long as a the looked up sitename starts with file\'s sitename it could be a valid match.\n\nThe date may have a four digit or two digit year.  If two digit, "20" is assumed as the default century, not "19".  A potential match must be with one day plus/minus the file\'s date to be considered a match.\n\nFinally the looked up scene name and all performers first and last names are combined in to what is called a powerset (every combo of including or not including each artist and/or scene name), and that is compared against the file\'s \'Scene.and.or.performer.name\' section with a tool called rapidfuzz.   A name must be 90% similar to a member of the powerset to be considered a match, though all potential matches are evaluated and sorted before selecting the best match.   Information about all potential matches are stored in the local log file if it is enabled.\n\nI\'m sold how do I install it!\n--------------------------------------------------\n\nYou have two choices.   Do you use docker?  Pull the docker image, here\'s docker-compose snippet to help you out.\n\n\n.. code-block:: yaml\n\n  version: "3"\n  services:  \n    namer:\n      container_name: namer\n      image: ghcr.io/4c0d3r/namer:latest\n      environment:\n        - PUID=1001\n        - PGID=1000\n        - TZ=America/Los_Angeles\n        - NAMER_CONFIG=/config/namer.cfg\n      volumes:\n        - /apps/namer/:/config <- this will store the namer.cfg file.\n        - /media:/data <- this will have the four folders namer needs to work, referenced in the config file.\n      restart: always\n\nCopy namer.cfg to your config location (a path mapped to /config/namer.cfg above), and set values for your setup.   \nThe config is well commented.\n\nRunning a service will occur automatically once you call ``docker-compose up``.  Now check out the configuration section below.\n\n\nPip/Python usage\n--------------------\n\nWhat if you don\'t want to use docker and/or containers?  Do you have python 3 and pip (sometimes pip3) and the command line tool ``ffmpeg`` installed locally?  If so,  ``pip install namer`` get\'s the job done.  If\nyou don\'t have python (3), pip and ``ffmpeg`` installed Homebrew_ can help you on Mac, and Chocolatey_ can help you on windows\n\n\n.. code-block:: sh\n\n  # install namer\n  pip3 install namer\n\n  #optionallly, set your configuration location, the below is the default:\n  export NAMER_CONFIG=${HOME}/.namer.cfg  \n\n  # Run the watchdog service:\n  python3 -m namer watchdog\n\n  # Or manually rename a file, dir, or all subdirs/subfiles of a dir:\n  # This calls the help method so that you can see the options.\n  python3 -m namer rename -h\n\n\nConfiguration:\n---------------------------\n\nThere is a well documented template of namer.cfg in this git repo, which is broken up in to three sections.\nOne section is related to command line renaming, the `namer section`_, one related to tagging mp4s `metadata section`_, \nand finally one related to the watchdog process `watchdog section`_.\nPlease note that the `namer section`_ section and the `watchdog section`_ \nsection both have a field to describe the new name of a file based on looked up metadata from the PornDB_.   \nThey differ because when run from the command line namer will keep the file "in place".  \nIf namer is passed a dir on the command line as input it can opperate in one of two modes,\nthe default mode is to look for the largest mp4 file, or mkv if no mp4 exists,\nand rename and move that file to the root of the folder (if it\'s in a subfolder).\nIn this case, by default the assumption is the name of the folder should be parsed to look for information to\nsearch the PornDB_ for matching rather than the file name.   Meaning,\nif you pass a file to namer on the commandline it will be renamed but stay in the same directory.\n\n\nTypical Watchdog Behavior:\n----------------------------\n\nThe watchdog process will watch a single folder, configured with watch_dir_ in the ``namer.cfg`` file.   Any new files and directories that appear in the watch_dir_\nwill be processed once an mp4/mkv file has been fully copied in to it.  \n\nThe first step in processing is to moce the newly appearing directory or file in to the work_dir_.  \n\nOnce moved the processing is highly dependant on the namer.cfg file, but in general, the name of video file or the directory file (configured with ``prefer_dir_name_if_available`` flag)\nis parsed and matched with a scene from the PornDB_.   See `For the curious, how is a match made?`_.  If a match cannot be made the general assumption is that the PornDB_ doesn\'t have metadata for that file yet.\nThe file is move to the failed dir fail_dir_ to be retried once a day at a time configured with retry_time_,\nwhich by default will be a random selected minute in the 3am hour of your timezone.   If enabled_tagging_ flag is set to true then\nthe metadata (including cover art if enable_poster_ is set) will be embedded in the mp4 file.  Please read the comments in the namer.cfg to find out about genres, tags, performers, etc.\n\nFinally, the file is movied to a location defined by dest_dir_ and new_relative_path_name_.\n\n\nDevelopment\n------------------------------\n\n.. code-block:: sh\n\n  # Building:\n  poetry build\n\n  # Linting:\n  poetry run pylint namer\n\n  # Testing:\n  poetry run pytest\n\n  # Code Coverage:\n  poetry run pytest --cov\n\n  # Html Coverage report:\n  poetry run coverage html\n\n  # Publishing:\n  # First make sure you have set gotten a token from pypi and set it on your machine.\n  poetry config pypi-token.pypi <token>\n\n  # Perhaps update the version number?\n\n  # Publishing a release to pypi.org:\n  poetry publish\n\n  # build docker file with:\n  ./docker_build.sh\n\n\n.. _PornDB: http://metadataapi.net/\n.. _namer section: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L1\n.. _metadata section: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L59\n.. _watchdog section: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L89\n.. _watch_dir: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L100\n.. _work_dir: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L104\n.. _fail_dir: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L109\n.. _dest_dir: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L112\n.. _retry_time: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L115\n.. _new_relative_path_name: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L97\n.. _enabled_tagging: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L67\n.. _enable_poster: https://github.com/4c0d3r/namer/blob/main/namer.cfg#L72\n.. _Homebrew: https://docs.brew.sh/Installation\n.. _Chocolatey: https://chocolatey.org/install',
    'author': '4c0d3r',
    'author_email': '4c0d3r@protonmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': None,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
