#๐ trying to use the yt api to convert videos to text
91 messages ยท Page 1 of 1 (latest)
@sick blade
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
things above are just connecting to the server with ssh and db
not all arguments converted during string formatting right now im stuck on this but running from one error to another for like the past 6 hours
What error are you facing? You haven't mentioned that
not all arguments converted during string formatting right
so it won t be converted to a str
You are facing issue during query generation?
yeah
Can you share the error?
Also please share the generated query if possible so that we can debug a bit easier
this is the error
cur.execute("""
INSERT INTO testytapi (test_id, testYTAPI)
VALUES (%s, %s)
ON CONFLICT (test_id)
DO UPDATE SET
testYTAPI = EXCLUDED.testYTAPI;
""", ( testYTAPI))
need it to be a text tho
yeahh it can be
The ( testYTAPI) at the end is suppose to be a 2-tuple of the test_id and the testYTAPI, not just the testYTAPI.
Yeah I think this must be the issue
Like (test_id, testYTAPI). But i don't know where the value for test_id should come from.
autogenerating
Ah, test_id is an automatic column.
You should be able to leave it out in the INSERT then. So:
INSERT INTO testytapi (testYTAPI)
VALUES (%s)
``` etc etc
Then you need a 1-tuple at the end to match the single %s.
But (testYTAPI) is not a 1-tuple, it's just testYTAPI (they're just brackets).
You want (testYTAPI,) - note the comma, which makes the value in the brackets a tuple.
No, you want to change (testYTAPI) to (testYTAPI,)
See how you've got a 5-tuple in the earlier INSERT? It's a list of values separated by commas.
So (1,2) is a 2-tuple. () is a 0-tuple. But (1) is just... 1. You need (1,) to make it a tuple.
This is because we use brackets for grouping, and the comma disambiguates from that.
yeah im not really and sql guy XD
This 1-tuple stuff is Python stuff.
But filling in the SQL parameters - you need the same number of values as the %ss in the query.
You'll need to learn some SQL.
maybe i will ask my dad (he is a datanalist) if i fell like it but im more into java and cpp just have to do this for uni
oh it is not defined
should be testYTAPI
lemme check my db really quick ๐
Well, it's looking better. See what's in the table now.
You should probably get rid of the except Exception as e:. It catches too much. You should only catch what you expect to happen. Other exceptions are bugs, to be investigated.
If you hadn't had that, the traceback would have identified the line the error occured on for you.
alright give me 5 min wanna complete my script to see if it prints longer texts
this is whisper so you can see it is way shorter than whisper but maybe it was still loading
will test this after that
thank you for the help tho could have never guessed i needed a , ๐
Yeah. That kind of fiddly syntax detail can be really hard to find.
doesn't YT do automatic transcriptions? Or is that not part of the API?
i get them from their api with an api key don t understand what you are trying to say
oh, so you want to use another model to make alternate transcripts?
It might just be a subtitle track in the video.
I've noticed that the automatic transcripts can be...off at times
i just meed the text to examine the sentiment of the videos
can't you just use the provided transcripts and then use an LLM on that?
I believe there are models that can demonstrably do that already
ewhh
I don't know what this is
that is the result with the yt api
with this
what are the IDs? is it possible that there's no speech in those given segments?
chnaged the 3d quary a bit and one return statement
looks a bit off nevertheless
I think the early rows (12..21) are an artifact of a bug since fixed.
sounds plausible
๐คทโโ๏ธ
It's the wrong variable name you fixed earlier.
what do you mean?
This:
except Exception as e:
print(f"Er trad een fout op bij het ophalen van de transcript voor video {video_id}: {e}")
return f"Fout opgetreden: {e}"
returns the NameError from your mistaken full_transcript variable as though it was the transcription.
but i don t have full_transcript anywhere
Yeah. But you did when rows 12..21 were inserted.
Look at the video itself in a browser? See if it's got almost no subtitles?
guess so but also have to fix something else now didn t set to only update
I'm going AFK. Good luck.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.