kabigon 0.6.0__py3-none-any.whl → 0.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kabigon/__init__.py +0 -1
 - kabigon/compose.py +6 -5
 - kabigon/errors.py +5 -5
 - kabigon/ytdlp.py +1 -1
 - {kabigon-0.6.0.dist-info → kabigon-0.6.1.dist-info}/METADATA +1 -1
 - {kabigon-0.6.0.dist-info → kabigon-0.6.1.dist-info}/RECORD +9 -10
 - kabigon/singlefile.py +0 -65
 - {kabigon-0.6.0.dist-info → kabigon-0.6.1.dist-info}/WHEEL +0 -0
 - {kabigon-0.6.0.dist-info → kabigon-0.6.1.dist-info}/entry_points.txt +0 -0
 - {kabigon-0.6.0.dist-info → kabigon-0.6.1.dist-info}/licenses/LICENSE +0 -0
 
    
        kabigon/__init__.py
    CHANGED
    
    
    
        kabigon/compose.py
    CHANGED
    
    | 
         @@ -3,18 +3,19 @@ from urllib.parse import urlunparse 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            from loguru import logger
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            from .errors import  
     | 
| 
      
 6 
     | 
    
         
            +
            from .errors import KabigonError
         
     | 
| 
       7 
7 
     | 
    
         
             
            from .loader import Loader
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
            REPLACEMENTS = {
         
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
      
 10 
     | 
    
         
            +
                # fixupx.com seems better than api.fxtwitter.com
         
     | 
| 
      
 11 
     | 
    
         
            +
                "fixupx.com": [
         
     | 
| 
       11 
12 
     | 
    
         
             
                    "twitter.com",
         
     | 
| 
       12 
13 
     | 
    
         
             
                    "x.com",
         
     | 
| 
       13 
14 
     | 
    
         
             
                    "fxtwitter.com",
         
     | 
| 
       14 
15 
     | 
    
         
             
                    "vxtwitter.com",
         
     | 
| 
       15 
16 
     | 
    
         
             
                    "fixvx.com",
         
     | 
| 
       16 
17 
     | 
    
         
             
                    "twittpr.com",
         
     | 
| 
       17 
     | 
    
         
            -
                    " 
     | 
| 
      
 18 
     | 
    
         
            +
                    "api.fxtwitter.com",
         
     | 
| 
       18 
19 
     | 
    
         
             
                ]
         
     | 
| 
       19 
20 
     | 
    
         
             
            }
         
     | 
| 
       20 
21 
     | 
    
         | 
| 
         @@ -49,7 +50,7 @@ class Compose(Loader): 
     | 
|
| 
       49 
50 
     | 
    
         
             
                        except Exception as e:
         
     | 
| 
       50 
51 
     | 
    
         
             
                            logger.info("[{}] Failed to load URL: {}, got error: {}", loader.__class__.__name__, url, e)
         
     | 
| 
       51 
52 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
                    raise  
     | 
| 
      
 53 
     | 
    
         
            +
                    raise KabigonError(f"Failed to load URL: {url}")
         
     | 
| 
       53 
54 
     | 
    
         | 
| 
       54 
55 
     | 
    
         
             
                async def async_load(self, url: str) -> str:
         
     | 
| 
       55 
56 
     | 
    
         
             
                    url = replace_domain(url)
         
     | 
| 
         @@ -68,4 +69,4 @@ class Compose(Loader): 
     | 
|
| 
       68 
69 
     | 
    
         
             
                        except Exception as e:
         
     | 
| 
       69 
70 
     | 
    
         
             
                            logger.info("[{}] Failed to load URL: {}, got error: {}", loader.__class__.__name__, url, e)
         
     | 
| 
       70 
71 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
                    raise  
     | 
| 
      
 72 
     | 
    
         
            +
                    raise KabigonError(f"Failed to load URL: {url}")
         
     | 
    
        kabigon/errors.py
    CHANGED
    
    | 
         @@ -1,23 +1,23 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            class  
     | 
| 
      
 1 
     | 
    
         
            +
            class KabigonError(Exception):
         
     | 
| 
       2 
2 
     | 
    
         
             
                pass
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            class FirecrawlKeyError( 
     | 
| 
      
 5 
     | 
    
         
            +
            class FirecrawlKeyError(KabigonError):
         
     | 
| 
       6 
6 
     | 
    
         
             
                def __init__(self) -> None:
         
     | 
| 
       7 
7 
     | 
    
         
             
                    super().__init__("FIRECRAWL_API_KEY is not set.")
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
            class FirecrawlError( 
     | 
| 
      
 10 
     | 
    
         
            +
            class FirecrawlError(KabigonError):
         
     | 
| 
       11 
11 
     | 
    
         
             
                def __init__(self, url: str, error: str) -> None:
         
     | 
| 
       12 
12 
     | 
    
         
             
                    msg = f"Failed to load URL: {url}, got: {error}"
         
     | 
| 
       13 
13 
     | 
    
         
             
                    super().__init__(msg)
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
            class NotPDFError( 
     | 
| 
      
 16 
     | 
    
         
            +
            class NotPDFError(KabigonError):
         
     | 
| 
       17 
17 
     | 
    
         
             
                def __init__(self, url: str) -> None:
         
     | 
| 
       18 
18 
     | 
    
         
             
                    super().__init__(f"URL is not a PDF: {url}")
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
            class NotReelURLError( 
     | 
| 
      
 21 
     | 
    
         
            +
            class NotReelURLError(KabigonError):
         
     | 
| 
       22 
22 
     | 
    
         
             
                def __init__(self, url: str):
         
     | 
| 
       23 
23 
     | 
    
         
             
                    super().__init__(f"URL is not an Instagram Reel: {url}")
         
     | 
    
        kabigon/ytdlp.py
    CHANGED
    
    
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            kabigon/__init__.py,sha256= 
     | 
| 
      
 1 
     | 
    
         
            +
            kabigon/__init__.py,sha256=_1LdKfp7qm0m7Fa_IJ9zcg4TRB14c9bB-r9M3fwASWI,498
         
     | 
| 
       2 
2 
     | 
    
         
             
            kabigon/cli.py,sha256=XSTyD1RFqq2Qok_52kSjJlBLUXl6t-K9QtsxCfB15o4,611
         
     | 
| 
       3 
     | 
    
         
            -
            kabigon/compose.py,sha256= 
     | 
| 
       4 
     | 
    
         
            -
            kabigon/errors.py,sha256= 
     | 
| 
      
 3 
     | 
    
         
            +
            kabigon/compose.py,sha256=5H_hWQ7ENUmEdeOpB2bkRv4U_U18_1IyNTran-cLYaM,2166
         
     | 
| 
      
 4 
     | 
    
         
            +
            kabigon/errors.py,sha256=3eSPQtLocreKuq9mhwRk7IMdA2xh8KkmIFEUhGmTPxg,618
         
     | 
| 
       5 
5 
     | 
    
         
             
            kabigon/firecrawl.py,sha256=Xnrlhco_R58x5kwGy9ZCKTnVqS4Pp-D3G0u-qnuGEsU,800
         
     | 
| 
       6 
6 
     | 
    
         
             
            kabigon/httpx.py,sha256=uDdLks6zVzirY7-mnsJkypX86kAI5XmUVfK-lFifdJA,895
         
     | 
| 
       7 
7 
     | 
    
         
             
            kabigon/loader.py,sha256=KhOJvlzLDM0o05o4VqMRgiyRVjofkzuGEcihQagj-8M,452
         
     | 
| 
         @@ -9,12 +9,11 @@ kabigon/pdf.py,sha256=yJcgkdMMF52baFsFxJp9Jn89KsTKBboLTLwD3gs6U5U,1775 
     | 
|
| 
       9 
9 
     | 
    
         
             
            kabigon/playwright.py,sha256=MZ-r0Ej2wWAOJkDLwYRvO77wcDvh38KXz2wgDsCTgm0,1358
         
     | 
| 
       10 
10 
     | 
    
         
             
            kabigon/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
         
     | 
| 
       11 
11 
     | 
    
         
             
            kabigon/reel.py,sha256=J2QOxGMYi_HaEscQPIipPEoHGN_iksGxR6pV_XvryME,929
         
     | 
| 
       12 
     | 
    
         
            -
            kabigon/singlefile.py,sha256=CeTT2WPYm0vb1xWPNdyBN4uHRw9hRqfZm68D-nEcUA8,1800
         
     | 
| 
       13 
12 
     | 
    
         
             
            kabigon/utils.py,sha256=eNTLtHLSB2erDac2HH3jWemgfr8Ou_ozwVb8h9BD-4g,922
         
     | 
| 
       14 
13 
     | 
    
         
             
            kabigon/youtube.py,sha256=HoiFNq0ookPL7_rO_wloBaY8yTIX6xP8A77F7y02q64,1166
         
     | 
| 
       15 
     | 
    
         
            -
            kabigon/ytdlp.py,sha256= 
     | 
| 
       16 
     | 
    
         
            -
            kabigon-0.6. 
     | 
| 
       17 
     | 
    
         
            -
            kabigon-0.6. 
     | 
| 
       18 
     | 
    
         
            -
            kabigon-0.6. 
     | 
| 
       19 
     | 
    
         
            -
            kabigon-0.6. 
     | 
| 
       20 
     | 
    
         
            -
            kabigon-0.6. 
     | 
| 
      
 14 
     | 
    
         
            +
            kabigon/ytdlp.py,sha256=_QRcyFx9s7NnI1MvcWdKKxlX-hHLnqtduCSL5_UH6dU,3140
         
     | 
| 
      
 15 
     | 
    
         
            +
            kabigon-0.6.1.dist-info/METADATA,sha256=78J35ClbTdy2-vU8GtlQWjgSTitntFI8J-Cz07FGqoo,1078
         
     | 
| 
      
 16 
     | 
    
         
            +
            kabigon-0.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
         
     | 
| 
      
 17 
     | 
    
         
            +
            kabigon-0.6.1.dist-info/entry_points.txt,sha256=O3FYAO9w-NQvlGMJrBvtrnGHSK2QkUnQBTa30YXRbVE,45
         
     | 
| 
      
 18 
     | 
    
         
            +
            kabigon-0.6.1.dist-info/licenses/LICENSE,sha256=H2T3_RTgmcngMeC7p_SXT3GwBLkd2DaNgAZuxulcfiA,1066
         
     | 
| 
      
 19 
     | 
    
         
            +
            kabigon-0.6.1.dist-info/RECORD,,
         
     | 
    
        kabigon/singlefile.py
    DELETED
    
    | 
         @@ -1,65 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import os
         
     | 
| 
       2 
     | 
    
         
            -
            import subprocess
         
     | 
| 
       3 
     | 
    
         
            -
            import tempfile
         
     | 
| 
       4 
     | 
    
         
            -
            from functools import cache
         
     | 
| 
       5 
     | 
    
         
            -
            from pathlib import Path
         
     | 
| 
       6 
     | 
    
         
            -
            from typing import Final
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            import charset_normalizer
         
     | 
| 
       9 
     | 
    
         
            -
            from loguru import logger
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            from .loader import Loader
         
     | 
| 
       12 
     | 
    
         
            -
            from .utils import html_to_markdown
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            DEFAULT_SINGLEFILE_PATH: Final[str] = "single-file"
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            @cache
         
     | 
| 
       18 
     | 
    
         
            -
            def get_singlefile_path() -> str:
         
     | 
| 
       19 
     | 
    
         
            -
                path = os.getenv("SINGLEFILE_PATH")
         
     | 
| 
       20 
     | 
    
         
            -
                if not path:
         
     | 
| 
       21 
     | 
    
         
            -
                    path = DEFAULT_SINGLEFILE_PATH
         
     | 
| 
       22 
     | 
    
         
            -
                    logger.warning("SINGLEFILE_PATH not set, using default: {}", DEFAULT_SINGLEFILE_PATH)
         
     | 
| 
       23 
     | 
    
         
            -
                return path
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            class SinglefileLoader(Loader):
         
     | 
| 
       27 
     | 
    
         
            -
                def __init__(self, cookies_file: str | None = None, browser_headless: bool = False) -> None:
         
     | 
| 
       28 
     | 
    
         
            -
                    self.cookies_file = cookies_file
         
     | 
| 
       29 
     | 
    
         
            -
                    self.browser_headless = browser_headless
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                def load(self, url: str) -> str:
         
     | 
| 
       32 
     | 
    
         
            -
                    filename = self.download(url)
         
     | 
| 
       33 
     | 
    
         
            -
                    content = str(charset_normalizer.from_path(filename).best())
         
     | 
| 
       34 
     | 
    
         
            -
                    return html_to_markdown(content)
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                def download(self, url: str) -> str:
         
     | 
| 
       37 
     | 
    
         
            -
                    logger.info("Downloading HTML using SingleFile: {}", url)
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                    filename = tempfile.mktemp(suffix=".html")
         
     | 
| 
       40 
     | 
    
         
            -
                    singlefile_path = get_singlefile_path()
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                    cmds = [singlefile_path]
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                    if self.cookies_file is not None:
         
     | 
| 
       45 
     | 
    
         
            -
                        cookies_path = Path(self.cookies_file)
         
     | 
| 
       46 
     | 
    
         
            -
                        if not cookies_path.exists():
         
     | 
| 
       47 
     | 
    
         
            -
                            raise FileNotFoundError(f"Cookies file not found: {self.cookies_file}")
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                        cmds += [
         
     | 
| 
       50 
     | 
    
         
            -
                            "--browser-cookies-file",
         
     | 
| 
       51 
     | 
    
         
            -
                            str(cookies_path),
         
     | 
| 
       52 
     | 
    
         
            -
                        ]
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                    cmds += [
         
     | 
| 
       55 
     | 
    
         
            -
                        "--filename-conflict-action",
         
     | 
| 
       56 
     | 
    
         
            -
                        "overwrite",
         
     | 
| 
       57 
     | 
    
         
            -
                        "--browser-headless",
         
     | 
| 
       58 
     | 
    
         
            -
                        str(self.browser_headless).lower(),
         
     | 
| 
       59 
     | 
    
         
            -
                        url,
         
     | 
| 
       60 
     | 
    
         
            -
                        filename,
         
     | 
| 
       61 
     | 
    
         
            -
                    ]
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                    subprocess.run(cmds)
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                    return filename
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |