| | |
| | | return completion.choices[0].message.content |
| | | |
| | | def get_film_works(): |
| | | url = "http://192.168.1.213:8090/flower/api/filmWorks/all" |
| | | url = "http://192.168.1.213:8090/flower/api/filmWorks/pending/create" |
| | | response = requests.get(url) |
| | | if response.status_code == 200: |
| | | return response.json().get("data", []) |
| | |
| | | # 为每个电影作品创建拍摄地点 |
| | | for film in film_works: |
| | | film_name = film.get("nameCn") |
| | | film_id = film.get("id") # 新增:获取电影ID |
| | | film_id = film.get("id") |
| | | if film_name: |
| | | print(f"正在处理电影: {film_name}") |
| | | |
| | |
| | | if location_info_list: |
| | | # 生成小红书文章 |
| | | article = generate_xiaohongshu_article(film_name, location_info_list) |
| | | # 清理文章中的HTML标记 |
| | | article = re.sub(r'```html|```', '', article) |
| | | print(f"\n生成的文章:\n{article}") |
| | | |
| | | # 生成游玩路线(JSON格式) |
| | |
| | | |
| | | # 生成小红书风格路线 |
| | | route_article = generate_xiaohongshu_route(film_name, location_info_list) |
| | | # 清理路线文章中的HTML标记 |
| | | route_article = re.sub(r'```html|```', '', route_article) |
| | | print(f"\n生成的路线文章:\n{route_article}") |
| | | |
| | | # 合并文章和路线 |
| | | combined_content = f"{article}\n\n{route_article}" |
| | | |
| | | # 保存到新接口 |
| | | save_url = "http://192.168.1.213:8090/flower/api/filmWorks/edit" |
| | | save_data = { |
| | | "id": film_id, |
| | | "type": "sys", |
| | | "filmContent": combined_content |
| | | } |
| | | save_response = requests.post(save_url, json=save_data) |
| | | print(f"保存到新接口结果: {save_response.json()}") |
| | | |
| | | # 为每个拍摄地点创建记录 |
| | | for location_info in location_info_list: |
| | | result = create_film_location(film_id, film_name, location_info, article, route_article) |
| | | print(f"创建拍摄地点 {location_info.get('locationName', '未知地点')} 结果: {result}") |
| | | |
| | | # 保存文章和路线 |
| | | # 保存文章和路线到文件 |
| | | save_article_and_route(film_id, film_name, article, route, route_article) |
| | | else: |
| | | print(f"未能获取到电影 {film_name} 的拍摄地点信息") |