Skip to content

Commit 9dae0b7

Browse files
author
freemty
committed
add videos
1 parent 6998089 commit 9dae0b7

File tree

105 files changed

+825
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+825
-244
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
videos_
2-
videos
32
.DS_Store

index.html

+777-243
Large diffs are not rendered by default.

remove_videos.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import os
2+
import re
3+
from bs4 import BeautifulSoup
4+
5+
def extract_video_paths(html_file):
6+
with open(html_file, 'r', encoding='utf-8') as file:
7+
soup = BeautifulSoup(file, 'html.parser')
8+
video_paths = set()
9+
for source_tag in soup.find_all('source'):
10+
src = source_tag.get('src')
11+
if src and src.startswith('./videos/'):
12+
video_paths.add(src.lstrip('./'))
13+
if src and src.startswith('videos/'):
14+
video_paths.add(src.lstrip('./'))
15+
return video_paths
16+
17+
def list_all_files(directory):
18+
all_files = set()
19+
for root, dirs, files in os.walk(directory):
20+
for file in files:
21+
file_path = os.path.join(root, file)
22+
relative_path = os.path.relpath(file_path, directory)
23+
all_files.add(relative_path)
24+
return all_files
25+
26+
def delete_unused_files(directory, used_files):
27+
all_files = set([os.path.join('videos', i) for i in list_all_files(directory)])
28+
unused_files = all_files - used_files
29+
for file in unused_files:
30+
file_path = file
31+
if os.path.isfile(file_path):
32+
os.remove(file_path)
33+
print(f"Deleted: {file_path}")
34+
35+
# 主函数
36+
def main():
37+
html_file = 'index.html'
38+
videos_directory = 'videos'
39+
40+
used_video_paths = extract_video_paths(html_file)
41+
print("Used video paths:")
42+
for path in used_video_paths:
43+
print(path)
44+
45+
delete_unused_files(videos_directory, used_video_paths)
46+
47+
if __name__ == "__main__":
48+
main()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)