| | import re
|
| | import os
|
| | from typing_extensions import Text
|
| |
|
| | directory = "videos/"
|
| | file_names = os.listdir(directory)
|
| |
|
| |
|
| | file_names = [f for f in file_names if os.path.isfile(os.path.join(directory, f)) and (f.endswith('.txt') or f.endswith('.mp4'))]
|
| |
|
| |
|
| | file_names.sort(key=lambda x: os.path.getmtime(os.path.join(directory, x)), reverse=True)
|
| |
|
| |
|
| | latest_files = {}
|
| | for file in file_names:
|
| | if file.endswith('.txt') and 'txt' not in latest_files:
|
| | latest_files['txt'] = file
|
| | elif file.endswith('.mp4') and 'mp4' not in latest_files:
|
| | latest_files['mp4'] = file
|
| | if len(latest_files) == 2:
|
| | break
|
| |
|
| |
|
| | text_file = latest_files.get('txt')
|
| | video_file = latest_files.get('mp4')
|
| | with open(os.path.join(directory, text_file), 'r') as file:
|
| | content = file.read()
|
| | title_match = re.search(r'---Youtube title---\n(.*?)\n', content, flags=re.DOTALL)
|
| | title = title_match.group(1) if title_match else None
|
| | description_match = re.search(r'---Youtube description---\n([\s\S]*)', content)
|
| | description = description_match.group(1) if description_match else None
|
| |
|
| |
|
| | if video_file and text_file:
|
| | os.system(f'python upload.py --file="{directory}{video_file}" --privacyStatus="public" --title="{title}" --description="{description}"')
|
| |
|