plexflow 0.0.132__py3-none-any.whl → 0.0.133__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.
@@ -3,11 +3,16 @@ from plexflow.core.plex.library.folders.assets.plex_asset import PlexAsset
3
3
 
4
4
 
5
5
  class PlexSubtitleAsset(PlexAsset):
6
- def __init__(self, path: str, root: Path, title: str, year: int, lang: str, index: int = None):
6
+ def __init__(self, path: str, root: Path, title: str, year: int, lang: str, index: int = None, season: int = None, episode: int = None):
7
7
  super().__init__(path, root, title, year)
8
8
  self.lang = lang
9
9
  self.index = index
10
+ self.season = season
11
+ self.episode = episode
10
12
 
11
13
  @property
12
14
  def target_path(self) -> Path:
13
- return self.root / Path(f"{self.title} ({self.year}){'.' + str(self.index) if self.index else ''}.{self.lang}" + self.ext)
15
+ if not self.season and not self.episode:
16
+ return self.root / Path(f"{self.title} ({self.year}){'.' + str(self.index) if self.index else ''}.{self.lang}" + self.ext)
17
+ else:
18
+ return self.root / Path(f"S{self.season:02d}E({self.episode:02d}){'.' + str(self.index) if self.index else ''}.{self.lang}" + self.ext)
@@ -1,5 +1,15 @@
1
1
  from plexflow.core.plex.library.folders.assets.plex_asset import PlexAsset
2
+ from pathlib import Path
2
3
 
3
4
  class PlexVideoAsset(PlexAsset):
4
- def __init__(self, path, root, title, year):
5
+ def __init__(self, path, root, title, year, season: int = None, episode: int = None):
5
6
  super().__init__(path, root, title, year)
7
+ self.season = season
8
+ self.episode = episode
9
+
10
+ @property
11
+ def target_path(self) -> Path:
12
+ if not self.season and not self.episode:
13
+ return self.root / Path(f"{self.title} ({self.year})" + self.ext)
14
+ else:
15
+ return self.root / Path(f"S{self.season:02d}E({self.episode:02d})" + self.ext)
@@ -0,0 +1,40 @@
1
+ import shutil as sh
2
+ import logging
3
+ from typing import List
4
+ from plexflow.core.plex.library.folders.plex_folder import PlexFolder
5
+ from plexflow.core.plex.library.folders.assets.plex_asset import PlexAsset
6
+ from plexflow.core.plex.library.folders.assets.plex_video_asset import PlexVideoAsset
7
+ from plexflow.core.plex.library.folders.assets.plex_subtitle_asset import PlexSubtitleAsset
8
+
9
+ class PlexShowFolder(PlexFolder):
10
+ def __init__(self, root, title, year, season: int, episode: int):
11
+ super().__init__(root, title, year)
12
+ self.assets: List[PlexAsset] = []
13
+ self.subtitle_index = None
14
+ self.season = season
15
+ self.episode = episode
16
+
17
+ def add_video_path(self, path: str):
18
+ video_asset = PlexVideoAsset(path, root=self.path_from_root(f"Season {self.season:02d}"), title=self.title, year=self.year, season=self.season, episode=self.episode)
19
+ self.assets.append(video_asset)
20
+
21
+ def add_subtitle_path(self, path: str, lang: str):
22
+ subtitle_asset = PlexSubtitleAsset(path, root=self.path_from_root(f"Season {self.season:02d}"), title=self.title, year=self.year, lang=lang, index=self.subtitle_index, season=self.season, episode=self.episode)
23
+ self.assets.append(subtitle_asset)
24
+ self.subtitle_index = self.subtitle_index + 1 if self.subtitle_index else 1
25
+
26
+ def create(self, dry_run: bool = False):
27
+ for asset in self.assets:
28
+ source = asset.source_path
29
+ target = asset.target_path
30
+
31
+ if not dry_run:
32
+ target.parent.mkdir(parents=True, exist_ok=True)
33
+
34
+ logging.info(f"moving {source} to {target}")
35
+
36
+ if not dry_run:
37
+ if isinstance(asset, PlexVideoAsset):
38
+ sh.move(src=str(source), dst=str(target))
39
+ else:
40
+ sh.copyfile(src=str(source), dst=str(target))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: plexflow
3
- Version: 0.0.132
3
+ Version: 0.0.133
4
4
  Summary: A short description of the package.
5
5
  License: MIT
6
6
  Keywords: keyword1,keyword2,keyword3
@@ -290,10 +290,11 @@ plexflow/core/plex/library/__pycache__/library.cpython-311.pyc,sha256=yL69reegO6
290
290
  plexflow/core/plex/library/__pycache__/library.cpython-312.pyc,sha256=6-TJWeb3YFArriMpzfMswXsBrlp3antN7QvUxr4LBaM,4518
291
291
  plexflow/core/plex/library/__pycache__/show.cpython-312.pyc,sha256=p0h8b6DtlcQak-HGZZeL31ToMsifkbNqQtbfDBT4tVM,3656
292
292
  plexflow/core/plex/library/folders/assets/plex_asset.py,sha256=awY8vhg3KoU2uCB18y5MleE3aAUdVDTnN1OaTmm2oJc,530
293
- plexflow/core/plex/library/folders/assets/plex_subtitle_asset.py,sha256=51itoIUbHco2HW0Mh9mGNddqwMrZA2ajwuyhVzPcXkI,521
294
- plexflow/core/plex/library/folders/assets/plex_video_asset.py,sha256=F_7RtdtblYQJc_gp9nUVxIfS4BeHl0eZDgYmTMg2zos,208
293
+ plexflow/core/plex/library/folders/assets/plex_subtitle_asset.py,sha256=nbbpDo8dbNkysDmVqbY8G4Jcc_lbo72oSXgj0KNeIxc,837
294
+ plexflow/core/plex/library/folders/assets/plex_video_asset.py,sha256=8gM44WGehvTrPPh3HMcNmE4HkZ9eNLJByqfer2HOoBo,616
295
295
  plexflow/core/plex/library/folders/plex_folder.py,sha256=GZnyQO6bzcire-2mxPjIPJrq8J0S_4uVsOfVCiHo2E0,387
296
296
  plexflow/core/plex/library/folders/plex_movie_folder.py,sha256=ns-3yf5VgikXc5IBeN8xPTtB9LHkPIQOZ4CsvcBZNU8,1672
297
+ plexflow/core/plex/library/folders/plex_show_folder.py,sha256=rPBNxBuVt4cfappqTbaHaa6faGDW_Ho1Tw6xjLXv6wU,1892
297
298
  plexflow/core/plex/library/library.py,sha256=taLi0e7iY0usZPDHXwPfLmxQI5vyMyo8eJtOSHNKtww,3644
298
299
  plexflow/core/plex/library/show.py,sha256=jAZfrjxoF_E1v0sdTpLmyx3NGWC3Uzil0XjJ8NkbUvQ,2648
299
300
  plexflow/core/plex/token/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -714,7 +715,7 @@ plexflow/utils/video/__pycache__/audio.cpython-312.pyc,sha256=kmzGDCHSC1hWyHwRut
714
715
  plexflow/utils/video/__pycache__/subtitle.cpython-312.pyc,sha256=PCjpCLydGXaRsQy6cikhgsEs8WlComfOoYPiLFqfVMA,2515
715
716
  plexflow/utils/video/audio.py,sha256=Pd8OuQHX2QN-lc5iYkB0Vo1OEHmTcvDYH-uKud1f1q4,5262
716
717
  plexflow/utils/video/subtitle.py,sha256=qPvvBjlPj0fynJJvGJgGeKt9ey26R-cF6EoLaYt9iXU,1333
717
- plexflow-0.0.132.dist-info/METADATA,sha256=tMNMebSsdsldEkn03tNHttSwAt8ewZ-c4wXHB_At2Ik,2971
718
- plexflow-0.0.132.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
719
- plexflow-0.0.132.dist-info/entry_points.txt,sha256=9RJC3ikOQORHNOn573EdwJOBUnFU_4EGHbtNUM5pjjY,1557
720
- plexflow-0.0.132.dist-info/RECORD,,
718
+ plexflow-0.0.133.dist-info/METADATA,sha256=i5Oj1D2JVpMhfeA7f5vv0EJ1cIujuiYpq1xY8prGbVw,2971
719
+ plexflow-0.0.133.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
720
+ plexflow-0.0.133.dist-info/entry_points.txt,sha256=9RJC3ikOQORHNOn573EdwJOBUnFU_4EGHbtNUM5pjjY,1557
721
+ plexflow-0.0.133.dist-info/RECORD,,