34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
||
import subprocess
|
||
import os
|
||
import sys
|
||
|
||
dst_dir = '/home/alexives/Desktop/архив с телефона/TikTok_видео'
|
||
os.makedirs(dst_dir, exist_ok=True)
|
||
|
||
res = subprocess.check_output(
|
||
['adb', '-s', '3aeea825', 'shell', 'ls /storage/emulated/0/DCIM/Camera'],
|
||
text=True
|
||
)
|
||
|
||
all_files = [f.strip() for f in res.splitlines() if f.strip()]
|
||
import re
|
||
pattern = re.compile(r'^[0-9a-f]{32}\.mp4$')
|
||
tiktok_files = [f for f in all_files if pattern.match(f)]
|
||
|
||
print(f"Total TikTok videos identified: {len(tiktok_files)}")
|
||
|
||
pulled = 0
|
||
for i, f in enumerate(tiktok_files, 1):
|
||
src = f"/storage/emulated/0/DCIM/Camera/{f}"
|
||
dst = os.path.join(dst_dir, f)
|
||
if os.path.exists(dst) and os.path.getsize(dst) > 0:
|
||
pulled += 1
|
||
continue
|
||
subprocess.run(['adb', '-s', '3aeea825', 'pull', src, dst_dir], check=True, stdout=subprocess.DEVNULL)
|
||
pulled += 1
|
||
if i % 50 == 0 or i == len(tiktok_files):
|
||
print(f"Progress: {i}/{len(tiktok_files)} videos pulled...")
|
||
|
||
print(f"All {pulled} TikTok videos successfully saved to {dst_dir}!")
|