From 9f1e6d5206228d2abc4cfb7a713af6b58f222aea Mon Sep 17 00:00:00 2001 From: lededev Date: Sat, 5 Jun 2021 21:00:35 +0800 Subject: [PATCH] video files must be regular files, links will be ignored --- ADC_function.py | 9 +++++++++ AV_Data_Capture.py | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ADC_function.py b/ADC_function.py index 63ea955..87a70cc 100644 --- a/ADC_function.py +++ b/ADC_function.py @@ -2,6 +2,7 @@ import requests import hashlib import pathlib import random +import os.path import uuid import json import time @@ -567,3 +568,11 @@ def file_modification_days(filename) -> int: if days < 0: return 9999 return days + +# 检查文件是否是链接 +def is_link(filename: str): + if os.path.islink(filename): + return True # symlink + elif os.stat(filename).st_nlink > 1: + return True # hard link Linux MAC OSX Windows NTFS + return False diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index 95dedc4..54afc0d 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -8,7 +8,7 @@ import urllib3 import config import time -from ADC_function import get_html +from ADC_function import get_html, is_link from number_parser import get_number from core import core_main @@ -44,7 +44,6 @@ def argparse_function(ver: str) -> [str, str, bool]: return args.file, args.path, args.number, args.autoexit - def movie_lists(root, escape_folder): if os.path.basename(root) in escape_folder: return [] @@ -56,7 +55,9 @@ def movie_lists(root, escape_folder): if os.path.isdir(f): total += movie_lists(f, escape_folder) elif os.path.splitext(f)[1].upper() in file_type: - total.append(os.path.abspath(f)) + absf = os.path.abspath(f) + if not is_link(absf): + total.append(absf) return total