comicpy


Namecomicpy JSON
Version 0.1.32 PyPI version JSON
download
home_pagehttps://github.com/kurotom/comicpy
SummaryTool to create CBR or CBZ files, supports PDF, ZIP, RAR files.
upload_time2024-04-07 00:42:32
maintainerNone
docs_urlNone
authorkurotom
requires_python<4.0,>=3.7
licenseNone
keywords comic cbz cbr manga
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # comicpy

Tool to create CBR or CBZ files.

Extracts images from PDF, ZIP, CBR files, generating comic files respecting their original order.


> [!Important]
>> The original files are not altered.
>


## Features

* Convert `PDF` file to `CBR` or `CBZ` files (by default).
* Convert `RAR` files to `CBR` files.
* Convert `ZIP` files to `CBZ` files.
* Scan in given directory and filter `PDF`, `ZIP`, `RAR` files depending on the given extension, convert them into `CBR` or `CBZ` files, generating individual files or consolidated into one.
* Scan in the given directory and filter `CBR`, `CBZ` files allowing to merge them all into one.
* Extract `CBR` or `CBZ` files from `RAR` or `ZIP` archives.
* Support for password protected `RAR` or `ZIP` archives.
* Convert image directories (*jpeg*, *png*, *jpg*) to `CBR` or `CBZ` files.


> [!Important]
>> 1. For full operation of `comicpy` when using RAR files, you must have available the `rar` command, download and install it from the official site, [**rarlab - rar/unrar command**](https://www.rarlab.com/download.htm).
>
>> 2. Some PDF files *contain multiple images on the same page*, which may be *repeated* within the *same file*; converting the PDF file <u>will remove all duplicate images</u>. <u>This is due to the original construction and layout of the source PDF file</u>. Therefore, as a result, there may be fewer or more pages compared to the original PDF file, this does *not necessarily indicate that the work of this tool (**comicpy**) is flawed or faulty*.
>
>> In continuous development of `comicpy`, any problem, suggestion, doubt, leave it in [*Issues*](https://github.com/kurotom/comicpy/issues) of the repository.
>


# Installation

```bash
pip install comicpy
```

# Usage

## CLI - usage

Command help.

```bash
$ comicpy -h
```

### File usage

| Command | Description |
|-|-|
| --type f | File. |
| -p PATH, --path PATH | Path of file. |
| -d DEST, --dest DEST | Path to save output files. Default is "." |
| --motorPDF {pypdf,pymupdf} | PDF library to use. |
| -c {rar,zip}, --compressor {rar,zip} | Type of compressor to use. |
| -o OUTPUT, --output OUTPUT | Prefix of output file. |
| --check | Check the CBR or CBZ files created. |
| -u {b,kb,mb,gb}, --unit {b,kb,mb,gb} | Unit of measure of data size. Default is "mb". |
| --password PASSWORD | Password of file protected. |
| --resize {preserve,small,medium,large} | Resize images. |
| --progress | Shows file in progress. |

```bash
$ comicpy --type f -p file.PDF --check -u kb
$
$ comicpy --type f -p file.rar --check
$
$ comicpy --type f -p file.zip --check --password PASS
$
$ comicpy --type f -p file.rar --check --resize small
```

### Directory usage

| Command | Description |
|-|-|
| --type d | Directory. |
| -p PATH, --path PATH | Path of directory. |
| --filter {pdf,rar,zip,cbr,cbz,images} | Filter files on directory. Default is "zip". |
| --motorPDF {pypdf,pymupdf} | PDF library to use. |
| -c {rar,zip}, --compressor {rar,zip} | Type of compressor to use. Default is "zip".|
| -d DEST, --dest DEST | Path to save output files. Default is ".".
| -o OUTPUT, --output OUTPUT | Prefix of output file. Default is "Converted_". |
| --check | Check the CBR or CBZ files created. |
| --join | Join or does not files thath are in the directory. Default is "False". |
| -u {b,kb,mb,gb}, --unit {b,kb,mb,gb} | Unit of measure of data size. Default is "mb". |
| --password PASSWORD | Password of file protected. |
| --resize {preserve,small,medium,large} | Resize images. |
| --progress | Shows file in progress. |


```bash
$ comicpy --type d -p rars_dir --filter rar -c rar --check --join -o prefix_final_ --password PASS
$ for i in $(ls -d Zip_Dir_*/); do
> comicpy --type d -p "$i" --filter zip -c zip --check -o ${i: 0:-1} --join
> done
$ comicpy --type d -p rars_dir --filter rar -c rar --check --join -o prefix_final_ --password PASS --resize preserve
$ comicpy --type d -p Comic_vol1/ --compress zip --filter images --check --progress --join
```



## Development - usage

> `path='.'` parameter indicates that files will be written by default to the current directory. It can be changed.

## Single PDF, RAR, ZIP file -> CBZ or CBR

```python
>>> from comicpy import ComicPy
>>>
>>> pdf_file = 'file_pdf.PDF'
>>>
>>> comic = ComicPy(unit='mb')
>>>
>>> metaFileCompress = comic.process_pdf(filename=pdf_file, compressor='zip')
>>>
>>> print(metaFileCompress)
[{'name': './file_pdf/file_pdf.cbz', 'size': '76.63 MB'}]
>>>
>>> comic.check_integrity(filename=metaFileCompress[0]['name'])
File is valid?:  "True"
True
>>>
>>> comic.check_integrity(filename=metaFileCompress[0]['name'], show=False)
True
>>>
```

## Directory with PDFs, RARs, ZIPs files -> CBZ or CBR

> The `join` parameter indicates whether all found files are merged or treated as individual files.


* Example, directory with RAR files - `join=False`


```python
>>> from comicpy import ComicPy
>>>
>>> dir_RAR = 'rars'
>>>
>>> comic = ComicPy(unit='GB')
>>>
>>> metaFileCompress = comic.process_dir(
...             filename='final_CBR_file',
...             directory_path=dir_RAR,
...             extention_filter='rar',
...             compressor='rar',
...             password=None,
...             join=False
...           )
>>> print(metaFileCompress)
[
  {'name': './final_CBR_file/chapter_1.cbr', 'size': '0.02 GB'},
  {'name': './final_CBR_file/chapter_2.cbr', 'size': '0.01 GB'}
]
>>>>
>>> for item in metaFileCompress:
...   comic.check_integrity(
...      filename=item['name'],
...      show=True
...   )
...
File is valid?:  "True"
True
File is valid?:  "True"
True
File is valid?:  "True"
True
File is valid?:  "True"
True
>>>
```


* Example, directory with RAR files - `join=True`

```python
>>> from comicpy import ComicPy
>>>
>>> dir_RAR = 'rars'
>>>
>>> comic = ComicPy(unit='GB')
>>>
>>> metaFileCompress = comic.process_dir(
...                 filename='final_CBR_file',
...                 directory_path=dir_RAR,
...                 extention_filter='rar',
...                 compressor='rar',
...                 password=None,
...                 join=True
...               )
>>> print(metaFileCompress)
[{'name': 'result/final_CBR_file/final_CBR_file.cbr', 'size': '0.05 GB'}]
>>>
>>> for item in metaFileCompress:
...   comic.check_integrity(
...      filename=item['name'],
...      show=True
...   )
...
File is valid?:  "True"
True
>>>
```

### Cloning, preparing the environment and running the tests

Linux environment.

```bash
git clone https://github.com/kurotom/comicpy.git

cd comicpy

poetry shell

poetry install

. run_tests.sh
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kurotom/comicpy",
    "name": "comicpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.7",
    "maintainer_email": null,
    "keywords": "comic, cbz, cbr, manga",
    "author": "kurotom",
    "author_email": "55354389+kurotom@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/94/02/4a856167c386556595e0c50194d2f55e8472d721326423d23ab684601b40/comicpy-0.1.32.tar.gz",
    "platform": null,
    "description": "# comicpy\n\nTool to create CBR or CBZ files.\n\nExtracts images from PDF, ZIP, CBR files, generating comic files respecting their original order.\n\n\n> [!Important]\n>> The original files are not altered.\n>\n\n\n## Features\n\n* Convert `PDF` file to `CBR` or `CBZ` files (by default).\n* Convert `RAR` files to `CBR` files.\n* Convert `ZIP` files to `CBZ` files.\n* Scan in given directory and filter `PDF`, `ZIP`, `RAR` files depending on the given extension, convert them into `CBR` or `CBZ` files, generating individual files or consolidated into one.\n* Scan in the given directory and filter `CBR`, `CBZ` files allowing to merge them all into one.\n* Extract `CBR` or `CBZ` files from `RAR` or `ZIP` archives.\n* Support for password protected `RAR` or `ZIP` archives.\n* Convert image directories (*jpeg*, *png*, *jpg*) to `CBR` or `CBZ` files.\n\n\n> [!Important]\n>> 1. For full operation of `comicpy` when using RAR files, you must have available the `rar` command, download and install it from the official site, [**rarlab - rar/unrar command**](https://www.rarlab.com/download.htm).\n>\n>> 2. Some PDF files *contain multiple images on the same page*, which may be *repeated* within the *same file*; converting the PDF file <u>will remove all duplicate images</u>. <u>This is due to the original construction and layout of the source PDF file</u>. Therefore, as a result, there may be fewer or more pages compared to the original PDF file, this does *not necessarily indicate that the work of this tool (**comicpy**) is flawed or faulty*.\n>\n>> In continuous development of `comicpy`, any problem, suggestion, doubt, leave it in [*Issues*](https://github.com/kurotom/comicpy/issues) of the repository.\n>\n\n\n# Installation\n\n```bash\npip install comicpy\n```\n\n# Usage\n\n## CLI - usage\n\nCommand help.\n\n```bash\n$ comicpy -h\n```\n\n### File usage\n\n| Command | Description |\n|-|-|\n| --type f | File. |\n| -p PATH, --path PATH | Path of file. |\n| -d DEST, --dest DEST | Path to save output files. Default is \".\" |\n| --motorPDF {pypdf,pymupdf} | PDF library to use. |\n| -c {rar,zip}, --compressor {rar,zip} | Type of compressor to use. |\n| -o OUTPUT, --output OUTPUT | Prefix of output file. |\n| --check | Check the CBR or CBZ files created. |\n| -u {b,kb,mb,gb}, --unit {b,kb,mb,gb} | Unit of measure of data size. Default is \"mb\". |\n| --password PASSWORD | Password of file protected. |\n| --resize {preserve,small,medium,large} | Resize images. |\n| --progress | Shows file in progress. |\n\n```bash\n$ comicpy --type f -p file.PDF --check -u kb\n$\n$ comicpy --type f -p file.rar --check\n$\n$ comicpy --type f -p file.zip --check --password PASS\n$\n$ comicpy --type f -p file.rar --check --resize small\n```\n\n### Directory usage\n\n| Command | Description |\n|-|-|\n| --type d | Directory. |\n| -p PATH, --path PATH | Path of directory. |\n| --filter {pdf,rar,zip,cbr,cbz,images} | Filter files on directory. Default is \"zip\". |\n| --motorPDF {pypdf,pymupdf} | PDF library to use. |\n| -c {rar,zip}, --compressor {rar,zip} | Type of compressor to use. Default is \"zip\".|\n| -d DEST, --dest DEST | Path to save output files. Default is \".\".\n| -o OUTPUT, --output OUTPUT | Prefix of output file. Default is \"Converted_\". |\n| --check | Check the CBR or CBZ files created. |\n| --join | Join or does not files thath are in the directory. Default is \"False\". |\n| -u {b,kb,mb,gb}, --unit {b,kb,mb,gb} | Unit of measure of data size. Default is \"mb\". |\n| --password PASSWORD | Password of file protected. |\n| --resize {preserve,small,medium,large} | Resize images. |\n| --progress | Shows file in progress. |\n\n\n```bash\n$ comicpy --type d -p rars_dir --filter rar -c rar --check --join -o prefix_final_ --password PASS\n$ for i in $(ls -d Zip_Dir_*/); do\n> comicpy --type d -p \"$i\" --filter zip -c zip --check -o ${i: 0:-1} --join\n> done\n$ comicpy --type d -p rars_dir --filter rar -c rar --check --join -o prefix_final_ --password PASS --resize preserve\n$ comicpy --type d -p Comic_vol1/ --compress zip --filter images --check --progress --join\n```\n\n\n\n## Development - usage\n\n> `path='.'` parameter indicates that files will be written by default to the current directory. It can be changed.\n\n## Single PDF, RAR, ZIP file -> CBZ or CBR\n\n```python\n>>> from comicpy import ComicPy\n>>>\n>>> pdf_file = 'file_pdf.PDF'\n>>>\n>>> comic = ComicPy(unit='mb')\n>>>\n>>> metaFileCompress = comic.process_pdf(filename=pdf_file, compressor='zip')\n>>>\n>>> print(metaFileCompress)\n[{'name': './file_pdf/file_pdf.cbz', 'size': '76.63 MB'}]\n>>>\n>>> comic.check_integrity(filename=metaFileCompress[0]['name'])\nFile is valid?:  \"True\"\nTrue\n>>>\n>>> comic.check_integrity(filename=metaFileCompress[0]['name'], show=False)\nTrue\n>>>\n```\n\n## Directory with PDFs, RARs, ZIPs files -> CBZ or CBR\n\n> The `join` parameter indicates whether all found files are merged or treated as individual files.\n\n\n* Example, directory with RAR files - `join=False`\n\n\n```python\n>>> from comicpy import ComicPy\n>>>\n>>> dir_RAR = 'rars'\n>>>\n>>> comic = ComicPy(unit='GB')\n>>>\n>>> metaFileCompress = comic.process_dir(\n...             filename='final_CBR_file',\n...             directory_path=dir_RAR,\n...             extention_filter='rar',\n...             compressor='rar',\n...             password=None,\n...             join=False\n...           )\n>>> print(metaFileCompress)\n[\n  {'name': './final_CBR_file/chapter_1.cbr', 'size': '0.02 GB'},\n  {'name': './final_CBR_file/chapter_2.cbr', 'size': '0.01 GB'}\n]\n>>>>\n>>> for item in metaFileCompress:\n...   comic.check_integrity(\n...      filename=item['name'],\n...      show=True\n...   )\n...\nFile is valid?:  \"True\"\nTrue\nFile is valid?:  \"True\"\nTrue\nFile is valid?:  \"True\"\nTrue\nFile is valid?:  \"True\"\nTrue\n>>>\n```\n\n\n* Example, directory with RAR files - `join=True`\n\n```python\n>>> from comicpy import ComicPy\n>>>\n>>> dir_RAR = 'rars'\n>>>\n>>> comic = ComicPy(unit='GB')\n>>>\n>>> metaFileCompress = comic.process_dir(\n...                 filename='final_CBR_file',\n...                 directory_path=dir_RAR,\n...                 extention_filter='rar',\n...                 compressor='rar',\n...                 password=None,\n...                 join=True\n...               )\n>>> print(metaFileCompress)\n[{'name': 'result/final_CBR_file/final_CBR_file.cbr', 'size': '0.05 GB'}]\n>>>\n>>> for item in metaFileCompress:\n...   comic.check_integrity(\n...      filename=item['name'],\n...      show=True\n...   )\n...\nFile is valid?:  \"True\"\nTrue\n>>>\n```\n\n### Cloning, preparing the environment and running the tests\n\nLinux environment.\n\n```bash\ngit clone https://github.com/kurotom/comicpy.git\n\ncd comicpy\n\npoetry shell\n\npoetry install\n\n. run_tests.sh\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Tool to create CBR or CBZ files, supports PDF, ZIP, RAR files.",
    "version": "0.1.32",
    "project_urls": {
        "Bug Tracker": "https://github.com/kurotom/comicpy/issues",
        "Homepage": "https://github.com/kurotom/comicpy",
        "Repository": "https://github.com/kurotom/comicpy"
    },
    "split_keywords": [
        "comic",
        " cbz",
        " cbr",
        " manga"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3fe59f381fbc61cef43270b684039dc6be34618c203935da9691b739107489cf",
                "md5": "cbe3ace8d83b4a66fbe39537811bdae3",
                "sha256": "95daab6356a81207358a09600bd20b3184b22d079c57cd6c1996000d5f028c4c"
            },
            "downloads": -1,
            "filename": "comicpy-0.1.32-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cbe3ace8d83b4a66fbe39537811bdae3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.7",
            "size": 501467,
            "upload_time": "2024-04-07T00:42:28",
            "upload_time_iso_8601": "2024-04-07T00:42:28.578151Z",
            "url": "https://files.pythonhosted.org/packages/3f/e5/9f381fbc61cef43270b684039dc6be34618c203935da9691b739107489cf/comicpy-0.1.32-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "94024a856167c386556595e0c50194d2f55e8472d721326423d23ab684601b40",
                "md5": "3f241abbb5d2d4e860c57f4e4e597a3d",
                "sha256": "66075fe5e1edbcbc0a1e14bb79fe7f1e73b321b9391bb2a6b5cd93c1b027b81c"
            },
            "downloads": -1,
            "filename": "comicpy-0.1.32.tar.gz",
            "has_sig": false,
            "md5_digest": "3f241abbb5d2d4e860c57f4e4e597a3d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.7",
            "size": 493135,
            "upload_time": "2024-04-07T00:42:32",
            "upload_time_iso_8601": "2024-04-07T00:42:32.190315Z",
            "url": "https://files.pythonhosted.org/packages/94/02/4a856167c386556595e0c50194d2f55e8472d721326423d23ab684601b40/comicpy-0.1.32.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-07 00:42:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kurotom",
    "github_project": "comicpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "comicpy"
}
        
Elapsed time: 0.38826s