movie-barcodes 0.0.3__tar.gz → 0.0.4__tar.gz

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.

Potentially problematic release.


This version of movie-barcodes might be problematic. Click here for more details.

Files changed (23) hide show
  1. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/PKG-INFO +1 -1
  2. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/movie_barcodes.egg-info/PKG-INFO +1 -1
  3. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/src/main.py +33 -39
  4. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/tests/test_integration.py +7 -20
  5. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/LICENSE +0 -0
  6. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/README.md +0 -0
  7. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/movie_barcodes.egg-info/SOURCES.txt +0 -0
  8. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/movie_barcodes.egg-info/dependency_links.txt +0 -0
  9. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/movie_barcodes.egg-info/entry_points.txt +0 -0
  10. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/movie_barcodes.egg-info/requires.txt +0 -0
  11. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/movie_barcodes.egg-info/top_level.txt +0 -0
  12. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/setup.cfg +0 -0
  13. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/setup.py +0 -0
  14. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/src/__init__.py +0 -0
  15. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/src/barcode_generation.py +0 -0
  16. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/src/color_extraction.py +0 -0
  17. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/src/utility.py +0 -0
  18. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/src/video_processing.py +0 -0
  19. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/tests/__init__.py +0 -0
  20. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/tests/test_barcode_generation.py +0 -0
  21. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/tests/test_color_extraction.py +0 -0
  22. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/tests/test_utility.py +0 -0
  23. {movie-barcodes-0.0.3 → movie-barcodes-0.0.4}/tests/test_video_processing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: movie-barcodes
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: Compress every frame of a movie in a single color barcode.Transform entire movies into stunning single-barcode visualizations.Capture the essence of cinematic storytelling through dominant color extraction from each frame.
5
5
  Home-page: https://github.com/Wazzabeee/movie-barcodes
6
6
  Author: Clément Delteil
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: movie-barcodes
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: Compress every frame of a movie in a single color barcode.Transform entire movies into stunning single-barcode visualizations.Capture the essence of cinematic storytelling through dominant color extraction from each frame.
5
5
  Home-page: https://github.com/Wazzabeee/movie-barcodes
6
6
  Author: Clément Delteil
@@ -90,35 +90,11 @@ def generate_and_save_barcode(args: argparse.Namespace, dominant_color_function:
90
90
  video.release()
91
91
 
92
92
 
93
- def main(args: argparse.Namespace) -> None:
93
+ def main() -> None:
94
94
  """
95
95
  Main function to generate a barcode from a video file.
96
-
97
- :param args: argparse.Namespace object containing the command-line arguments
98
- :return: None
99
96
  """
100
- # Check if the input video file exists
101
- _, frame_count, _, _ = load_video(args.input_video_path)
102
-
103
- # Check if the arguments are valid
104
- validate_args(args, frame_count, MAX_PROCESSES, MIN_FRAME_COUNT)
105
-
106
- # Get a list of all available methods
107
- methods = ["avg", "hsv", "bgr", "kmeans"]
108
-
109
- # Check if all_methods flag is set
110
- if args.all_methods:
111
- for method in methods:
112
- # Generate barcodes for each method
113
- dominant_color_function = get_dominant_color_function(method)
114
- generate_and_save_barcode(args, dominant_color_function, method)
115
- else:
116
- # Use the specified method to generate barcode
117
- dominant_color_function = get_dominant_color_function(args.method)
118
- generate_and_save_barcode(args, dominant_color_function, args.method)
119
-
120
-
121
- if __name__ == "__main__":
97
+ # Logging configuration
122
98
  logging.basicConfig(
123
99
  filename=path.join("..", "logs.txt"),
124
100
  level=logging.INFO,
@@ -127,8 +103,9 @@ if __name__ == "__main__":
127
103
  header_msg = "=" * 40 + " NEW RUN " + "=" * 40
128
104
  logging.info("\n%s\n", header_msg)
129
105
 
106
+ # Argument parser setup
130
107
  parser = argparse.ArgumentParser(description="Generate a color barcode from a video file.")
131
- parser.add_argument("--input_video_path", type=str, help="Path to the video file.")
108
+ parser.add_argument("--input_video_path", type=str, required=True, help="Path to the video file.")
132
109
  parser.add_argument(
133
110
  "--destination_path",
134
111
  type=str,
@@ -146,16 +123,15 @@ if __name__ == "__main__":
146
123
  "--method",
147
124
  choices=["avg", "kmeans", "hsv", "bgr"],
148
125
  default="avg",
149
- help="Method to extract dominant color: avg (average), kmeans (K-Means clustering), hsv (HSV "
150
- "histogram), or bgr (BGR histogram). Default is avg.",
126
+ help="Method to extract dominant color: avg (average), kmeans (K-Means clustering), hsv (HSV histogram), "
127
+ "or bgr (BGR histogram). Default is avg.",
151
128
  )
152
129
  parser.add_argument(
153
130
  "--workers",
154
131
  type=int,
155
132
  default=None,
156
- help="Number of workers for parallel processing. Default behavior uses all available CPU cores."
157
- "Setting this to 1 will use sequential processing. Do not specify a value greater than "
158
- "the number of available CPU cores.",
133
+ help="Number of workers for parallel processing. Default behavior uses all available CPU cores. Setting this "
134
+ "to 1 will use sequential processing.",
159
135
  )
160
136
  parser.add_argument(
161
137
  "--width",
@@ -167,15 +143,33 @@ if __name__ == "__main__":
167
143
  "--output_name",
168
144
  type=str,
169
145
  nargs="?",
170
- help="Custom name for the output barcode image. If not provided, a name will be automatically " "generated.",
146
+ help="Custom name for the output barcode image. If not provided, a name will be automatically generated.",
171
147
  default=None,
172
148
  )
173
149
  parser.add_argument(
174
150
  "--all_methods",
175
- type=bool,
176
- default=False,
177
- help="If provided, all methods to extract dominant color will be used to create barcodes. "
178
- "Overrides --method argument.",
151
+ action="store_true",
152
+ help="If provided, all methods to extract dominant color will be used to create barcodes. Overrides --method "
153
+ "argument.",
179
154
  )
180
- arguments = parser.parse_args()
181
- main(arguments)
155
+
156
+ # Parse arguments
157
+ args = parser.parse_args()
158
+
159
+ # Validate and process video file
160
+ _, frame_count, _, _ = load_video(args.input_video_path)
161
+ validate_args(args, frame_count, MAX_PROCESSES, MIN_FRAME_COUNT)
162
+
163
+ # Choose the method to generate barcode
164
+ methods = ["avg", "hsv", "bgr", "kmeans"]
165
+ if args.all_methods:
166
+ for method in methods:
167
+ dominant_color_function = get_dominant_color_function(method)
168
+ generate_and_save_barcode(args, dominant_color_function, method)
169
+ else:
170
+ dominant_color_function = get_dominant_color_function(args.method)
171
+ generate_and_save_barcode(args, dominant_color_function, args.method)
172
+
173
+
174
+ if __name__ == "__main__":
175
+ main()
@@ -1,31 +1,20 @@
1
- import argparse
2
1
  import unittest
3
2
  import os
4
3
  import glob
4
+ import sys
5
+ from unittest.mock import patch
5
6
 
6
7
  from src import main
7
8
 
8
9
 
9
10
  class TestIntegration(unittest.TestCase):
10
11
  def setUp(self) -> None:
11
- """
12
- Set up the test case.
13
- """
14
- # Recreate the parser with minimal necessary setup
15
- self.parser = argparse.ArgumentParser(description="Test Parser")
16
- self.parser.add_argument("--input_video_path", type=str)
17
- self.parser.add_argument("--destination_path", type=str, nargs="?", default=None)
18
- self.parser.add_argument("--barcode_type", choices=["horizontal", "circular"], default="horizontal")
19
- self.parser.add_argument("--method", choices=["avg", "kmeans", "hsv", "bgr"], default="avg")
20
- self.parser.add_argument("--workers", type=int, default=None)
21
- self.parser.add_argument("--width", type=int, default=None)
22
- self.parser.add_argument("--output_name", type=str, nargs="?", default=None)
23
- self.parser.add_argument("--all_methods", type=bool, default=False)
24
-
25
12
  self.input_video_path = "tests/sample.mp4"
26
13
 
27
14
  def _run_test(self, barcode_type, workers, width=None):
15
+ # Build the command line arguments list
28
16
  args = [
17
+ "movie-barcodes",
29
18
  "--input_video_path",
30
19
  self.input_video_path,
31
20
  "--barcode_type",
@@ -38,11 +27,9 @@ class TestIntegration(unittest.TestCase):
38
27
  if width is not None:
39
28
  args.extend(["--width", str(width)])
40
29
 
41
- # Parse args using the recreated parser
42
- parsed_args = self.parser.parse_args(args)
43
-
44
- # Execute the program with the parsed Namespace object
45
- main.main(parsed_args)
30
+ # Use patch to simulate command line arguments
31
+ with patch.object(sys, "argv", args):
32
+ main.main() # Call the main function which now internally handles args
46
33
 
47
34
  def test_horizontal_1_worker_default_width(self):
48
35
  self._run_test("horizontal", 1)
File without changes
File without changes
File without changes
File without changes