File size: 1,279 Bytes
f7a42c7
 
fde6ed4
 
 
 
f7a42c7
 
fde6ed4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f7a42c7
 
 
 
 
 
 
 
 
 
 
fde6ed4
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from youtube_transcript_api import YouTubeTranscriptApi
import pandas as pd
from langchain_experimental.utilities import PythonREPL
from langchain_core.tools import Tool
from contextlib import redirect_stdout
import io


python_repl = PythonREPL()
def read_python_file(file_path: str) -> str:
    """Reads a Python file and returns its code as a string."""
    with open(file_path, 'r', encoding='utf-8') as f:
        return f.read()
python_str = read_python_file('results/f918266a-b3e0-4914-865d-4faa564f1aef.py')
# Prepara un buffer per catturare stdout
f = io.StringIO()
with redirect_stdout(f):
    # Esegui il codice come se fosse in un file .py
    exec(python_str, {"__name__": "__main__"})

# Ottieni tutto ciò che è stato stampato
output = f.getvalue()
print("=== OUTPUT ===")
print(output)

# def get_youtube_transcript(video_url: str) -> list:
#     """Fetches the transcript of a YouTube video."""
#     ytt_api = YouTubeTranscriptApi()
#     fetched_transcript = ytt_api.fetch(video_url)
#     return fetched_transcript.to_raw_data()

# url = '1htKBjuUWec'
# transcript = get_youtube_transcript(url)
# print(transcript)

# Leggi un file xlsx con pandas
# file_path = 'results/7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx'
# df = pd.read_excel(file_path)
# print(df)