Skip to content

Commit a927cfb

Browse files
committed
Merged branch test into main
2 parents 03f002c + 8235abf commit a927cfb

18 files changed

+137
-54
lines changed

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ disable=W0703,
6969
R0401,
7070
W0611,
7171
C0415,
72-
W0602
72+
W0602,
73+
R0913
7374

7475
# Enable the message, report, category or checker with the given id(s). You can
7576
# either give multiple identifier separated by comma (,) or put this option

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.1.5 - 2021-10-12]
6+
7+
### Added
8+
9+
- Added some action loaders on Details page
10+
- Added links to the list of target directories
11+
12+
### Fixed
13+
14+
- Fixed video processing broken by previous update.
15+
- Fixed pip version parsing, install now works with last pip.
16+
- Fixed processing files from other NC instances and remote shares.
17+
518
## [0.1.4 - 2021-10-09]
619

720
### Fixed

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This app allows to find duplicate or similar 📸📹 photos and videos
1717
Quick start guide and further information in our [Wiki](https://github.com/andrey18106/mediadc/wiki).
1818
]]>
1919
</description>
20-
<version>0.1.4</version>
20+
<version>0.1.5</version>
2121
<licence>agpl</licence>
2222
<author mail="andrey18106x@gmail.com" homepage="https://github.com/andrey18106">Andrey Borysenko</author>
2323
<author mail="bigcat88@icloud.com" homepage="https://github.com/bigcat88">Alexander Piskun</author>

js/mediadc-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/mediadc-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/mediadc-node_modules_moment_locale_sync_recursive_-src_views_CollectorDetails_vue.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/mediadc-node_modules_moment_locale_sync_recursive_-src_views_CollectorDetails_vue.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Service/python/db/occ_cloud.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ def occ_call(occ_task, *params, decode: bool = True) -> [bool, Union[str, bytes]
8787
success, result = php_call(OCC, '--no-warnings', occ_task, *params, decode=decode)
8888
if not success:
8989
return False, result
90-
clear_result = re.sub(r'.*app.*require.*upgrade.*\n?', '', result, flags=re.IGNORECASE)
91-
clear_result = re.sub(r'.*occ.*upgrade.*command.*\n?', '', clear_result, flags=re.IGNORECASE)
92-
clear_result = clear_result.strip('\n')
93-
return True, clear_result
90+
if decode:
91+
clear_result = re.sub(r'.*app.*require.*upgrade.*\n?', '', result, flags=re.IGNORECASE)
92+
clear_result = re.sub(r'.*occ.*upgrade.*command.*\n?', '', clear_result, flags=re.IGNORECASE)
93+
clear_result = clear_result.strip('\n')
94+
return True, clear_result
95+
return True, result
9496

9597

9698
def get_cloud_config_value(value_name: str) -> [bool, str]:

lib/Service/python/dc_videos.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ def process_video_hash(algo: str, hash_size: int, file_info: dict, data_dir: str
120120
full_path = get_file_full_path(data_dir, file_info['storage'], file_info['path'])
121121
if not full_path:
122122
break
123-
video_info = ffprobe_get_video_info(full_path)
123+
video_info = ffprobe_get_video_info(full_path, None)
124124
if not video_info:
125125
break
126-
if not do_hash_video(algo, hash_size, video_info, file_info, full_path):
126+
if not do_hash_video(algo, hash_size, video_info, file_info, full_path, None):
127127
raise InvalidVideo
128128
return
129129
if file_info['size'] > remote_filesize_limit:
@@ -133,10 +133,10 @@ def process_video_hash(algo: str, hash_size: int, file_info: dict, data_dir: str
133133
data = request_file_from_php(file_info)
134134
if len(data) == 0:
135135
return
136-
video_info = ffprobe_get_video_info(data)
136+
video_info = ffprobe_get_video_info(None, data)
137137
if not video_info.get('fast_start', False):
138138
raise InvalidVideo
139-
if not do_hash_video(algo, hash_size, video_info, file_info, data):
139+
if not do_hash_video(algo, hash_size, video_info, file_info, None, data):
140140
raise InvalidVideo
141141
except Exception as exception_info:
142142
store_err_video_hash(file_info['fileid'], video_info.get('duration', 0),
@@ -146,15 +146,16 @@ def process_video_hash(algo: str, hash_size: int, file_info: dict, data_dir: str
146146
print(f"Exception({exception_name}): `{file_info['path']}`:\n`{str(traceback.format_exc())}`")
147147

148148

149-
def do_hash_video(algo: str, hash_size: int, video_info: dict, file_info: dict, path_or_data) -> bool:
149+
def do_hash_video(algo: str, hash_size: int, video_info: dict, file_info: dict, path, data) -> bool:
150+
"""Accepts path(bytes/str) or data for processing in memory."""
150151
if video_info['duration'] < MinVideoDuration_ms:
151152
return False
152-
first_timestamp = get_first_timestamp(video_info, path_or_data)
153+
first_timestamp = get_first_timestamp(video_info, path, data)
153154
if first_timestamp == -1:
154155
return False
155156
frames_timestamps = build_times_for_hashes(video_info['duration'], first_timestamp)
156157
ex = ()
157-
res = get_frames(frames_timestamps, path_or_data, *ex)
158+
res = get_frames(frames_timestamps, path, data, *ex)
158159
if not res[0]:
159160
return False
160161
if any(len(x) == 0 for x in res[1:]):
@@ -192,19 +193,22 @@ def get_max_first_frame_time(duration_ms) -> int:
192193
return max_timestamp
193194

194195

195-
def get_first_timestamp(video_info: dict, data_or_filepath) -> int:
196+
def get_first_timestamp(video_info: dict, path, data) -> int:
197+
"""Accepts path(bytes/str) or data for processing in memory."""
196198
max_timestamp = get_max_first_frame_time(video_info['duration'])
197199
ffmpeg_input_params = ['-hide_banner', '-loglevel', 'fatal', '-an', '-sn', '-dn', '-to', f'{max_timestamp}ms']
198-
if isinstance(data_or_filepath, str):
199-
result, err = stub_call_ff('ffmpeg', *ffmpeg_input_params, '-i', data_or_filepath,
200+
if path is not None:
201+
result, err = stub_call_ff('ffmpeg', *ffmpeg_input_params, '-i', path,
200202
'-f', 'rawvideo', '-s', f'{FirstFrameResolution}x{FirstFrameResolution}',
201203
'-pix_fmt', 'rgb24', 'pipe:'
202204
)
203-
else:
205+
elif data is not None:
204206
result, err = stub_call_ff('ffmpeg', *ffmpeg_input_params, '-i', 'pipe:0',
205207
'-f', 'rawvideo', '-s', f'{FirstFrameResolution}x{FirstFrameResolution}',
206208
'-pix_fmt', 'rgb24', 'pipe:1',
207-
stdin_data=data_or_filepath)
209+
stdin_data=data)
210+
else:
211+
raise ValueError("`path` or `data` argument must be specified.")
208212
if err:
209213
print('DEBUG:', err)
210214
return -1
@@ -223,22 +227,25 @@ def get_first_timestamp(video_info: dict, data_or_filepath) -> int:
223227
return 0
224228

225229

226-
def get_frames(timestamps: list, data_or_filepath, *ffmpeg_out_params) -> list:
230+
def get_frames(timestamps: list, path, data, *ffmpeg_out_params) -> list:
231+
"""Accepts path(bytes/str) or data for processing in memory."""
227232
ret = [False]
228233
for _ in range(len(timestamps)):
229234
ret.append(b'')
235+
if path is None and data is None:
236+
raise ValueError("`path` or `data` argument must be specified.")
230237
ffmpeg_input_params = ['-hide_banner', '-loglevel', 'fatal', '-an', '-sn', '-dn']
231238
for index, timestamp in enumerate(timestamps):
232-
if isinstance(data_or_filepath, str):
239+
if path is not None:
233240
result, err = stub_call_ff('ffmpeg', *ffmpeg_input_params,
234-
'-ss', f'{timestamp}ms', '-i', data_or_filepath,
241+
'-ss', f'{timestamp}ms', '-i', path,
235242
'-f', 'image2', '-c:v', 'bmp', '-frames', '1', *ffmpeg_out_params, 'pipe:'
236243
)
237244
else:
238245
result, err = stub_call_ff('ffmpeg', *ffmpeg_input_params,
239246
'-ss', f'{timestamp}ms', '-i', 'pipe:0',
240247
'-f', 'image2', '-c:v', 'bmp', '-frames', '1', *ffmpeg_out_params, 'pipe:1',
241-
stdin_data=data_or_filepath)
248+
stdin_data=data)
242249
if err:
243250
print('DEBUG:', err)
244251
return ret

lib/Service/python/ffmpeg_probe.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,23 @@ def is_moov_at_start(std_log) -> bool:
8787
return False
8888

8989

90-
def ffprobe_get_video_info(path_or_data) -> dict:
91-
"""Accepts bytes/path. Returns {} or {duration:X ms}. If input is bytes also returns `fast_start` flag."""
92-
if isinstance(path_or_data, str):
90+
def ffprobe_get_video_info(path, data) -> dict:
91+
"""Accepts path(bytes/str) or data. Returns {} or {duration:X ms}. For data input also returns `fast_start` flag."""
92+
if path is not None:
9393
result, err = stub_call_ff('ffprobe', '-hide_banner', '-loglevel', 'fatal', '-print_format', 'json',
9494
'-show_entries', 'format=duration',
95-
path_or_data)
96-
else:
95+
path)
96+
elif data is not None:
9797
result, err = stub_call_ff('ffprobe', '-hide_banner', '-loglevel', 'trace', '-print_format', 'json',
9898
'-show_entries', 'format=duration', '-i', 'pipe:0',
99-
stdin_data=path_or_data, ignore_errors=True)
99+
stdin_data=data, ignore_errors=True)
100+
else:
101+
raise ValueError("`path` or `data` argument must be specified.")
100102
if err:
101103
print(err)
102104
return {}
103105
ret = ffprobe_parse_results(result)
104-
if isinstance(path_or_data, bytes):
106+
if path is None:
105107
if ret['duration'] != 0:
106108
ret['fast_start'] = is_moov_at_start(result.stderr)
107109
return ret

0 commit comments

Comments
 (0)