import pandas as pd
import os
# 1. 설정 정보
folder_name = 'pm_backup'
file_name = '6325918632821307184_MIYEON_chats.csv'
PROFILE_IMG_URL = "https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2Fp6R6p%2FdJMcab42Vnt%2FAAAAAAAAAAAAAAAAAAAAAATNvA1icsWl45OsfcBSeX3Ypg2Uu_EwkVB6-Y0S8YyT%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1777561199%26allow_ip%3D%26allow_referer%3D%26signature%3D7KAMsOtALfkl6HKagOXhhKOw8Dw%253D"
desktop = os.path.join(os.path.expanduser("~"), "Desktop")
base_path = os.path.join(desktop, folder_name)
input_path = os.path.join(base_path, file_name)
output_folder = os.path.join(base_path, 'daily_files_html_video')
if not os.path.exists(output_folder):
os.makedirs(output_folder)
if os.path.exists(input_path):
print("🔗 주소 삽입이 가능한 HTML 비디오 버전을 생성 중입니다...")
df = pd.read_csv(input_path)
df = df[df['nickname'] != '애기'].copy()
df['message'] = df['message'].astype(str).str.replace('애기', '@@', regex=False)
df['datetime'] = pd.to_datetime(df['datetime(UTC)'])
df['date'] = df['datetime'].dt.date
df['time_key'] = df['datetime'].dt.strftime('%H:%M')
style_code = """
"""
for date, group in df.groupby('date'):
file_path = os.path.join(output_folder, f"{date}.txt")
group = group.reset_index(drop=True)
with open(file_path, 'w', encoding='utf-8-sig') as f:
f.write(style_code)
f.write(f'
\n')
f.write(f'\n
\n{date}
\n')
last_time = ""
for i, row in group.iterrows():
current_time = row['time_key']
show_time = (i + 1 == len(group)) or (current_time != group.loc[i+1, 'time_key'])
if current_time != last_time:
if i != 0: f.write(' \n
\n
\n\n
\n{row["nickname"]}
\n')
f.write(f' \n')
msg = str(row['message'])
is_media = msg.lower().endswith(('.mov', '.mp4', '.jpeg', '.jpg', '.png', '.gif'))
if is_media:
# ⭐ 비디오 주소를 넣을 수 있는 태그로 생성
if msg.lower().endswith(('.mov', '.mp4')):
f.write(f'
\n')
else:
f.write(f'
\n')
last_time = current_time
f.write(' \n')
f.write(f' \n')
f.write(f'
\n')
else:
f.write(f' ↑ src="" 안에 복사한 주소 넣기 ({msg})
\n')
f.write(f' {msg}
\n')
if show_time:
f.write(f' {current_time}
\n')
f.write(f' '2021' 카테고리의 다른 글
| 2021-04-12 (0) | 2026.04.25 |
|---|---|
| 2021-04-06 (0) | 2026.04.25 |
| 2021-04-04 (0) | 2026.04.25 |
| 2021-04-01 (0) | 2026.04.25 |
| 2021-03-30 (0) | 2026.04.25 |