import package as pkg from package import GetConfig, MariaDB, ChangeTextToPost, WordPress import markdown # 2024-10-03 환경 변수 호출 print('### Get values From .env') config = GetConfig() dict_data = config.get_config_as_dict() # 2024-10-03 db에서 url정보 호출 # DB없이 url을 직접 넣어서 동작시켜도 가능합니다. - 2025.01.19 print('### Get URL From DB') db = MariaDB(dict_data) url = db.fetch_data_from_mariadb()['url'] # 최근 항목 조회. - 2025.01.19 # 2024-10-03 url을 이용해서 text추출 print('### Get content From URL') origin_content = pkg.getContents(url) # 2024-10-03 openAI를 이용하여 게시글 스타일 변경 print('### Convert to Post - openAI') openai_key = dict_data['openai_api_key'] wp_reference_style = dict_data['wp_post_style'] open_ai = ChangeTextToPost(openai_key) post_article = open_ai.generate_blog_post(origin_content, wp_reference_style) print('### Convert to HTML - markdown to html') # 2024-10-03 Markdown을 HTML로 변환 html = markdown.markdown(post_article) # 2024-10-03 워드프레스 포스팅 임시등록 print('### Create post') wp = WordPress(dict_data) rs = wp.create_post(2,html) if __name__ == "__main__": # print(post_article) print("추가 확인을 위한 출력") if rs.ok: print(f"### 성공 code:{rs.status_code}") else: print(f"### 실패 code:{rs.status_code} reason:{rs.reason} msg:{rs.text}")