Is it possible to iterate all the video sessions from the site using API?
Hi,
I'm tring to download all the captions from all the videos on my site, and so I'm using Session API which can return me the caption download url.
However, the Session API requires me to specify the session id, and so I have to manually click into each video to grab the session id. And btw, is this the correct way to get the caption file?
Best
Best Answers
-
Adis Hrnjica Tyro
Hi Xun,
There is API which can return list of sessions for a specific folder. This would speed up your work, since in that case you would not need to get session id for every session.
That is our Folder API (https://demo.hosted.panopto.com/Panopto/api/docs/index.html#/Folders/Folders_GetSessions).
That should be the correct way, since if captions are present on the session, you should see url to download captions.
I hope this helps. Please let me know if you have any other questions.
Thanks,
Adis
1 -
Adis Hrnjica Tyro
Hi Xun,
I have tried just now and I can see this caption being download into the following file.
See my code sample below:
from urllib import request # Define the remote file to retrieve remote_url = 'https://sph.hosted.panopto.com/Panopto/Pages/Transcription/GenerateSRT.ashx?id=c4c986d0-eb6d-4d2f-ab01-ae9f00f2aee9&language=English_USA' # Define the local filename to save data local_file = 'sph_caption.txt' # Download remote and save locally request.urlretrieve(remote_url, local_file)
If you wish you can send me your piece of logic so I can check it.
Thanks,
Adis
0
Answers
Hi Adis,
Thank you, it works! Another question is I'm trying to use Python and CaptionDownloadUrl to download the caption into json.
A sample caption link will be like this (https://sph.hosted.panopto.com/Panopto/Pages/Transcription/GenerateSRT.ashx?id=c4c986d0-eb6d-4d2f-ab01-ae9f00f2aee9&language=English_USA)
However, I have tried using requests library or urllib.request library, but both returns me an empty string. Therefore, I'm wondering if there is any other method that I can download the caption?
Thank you!
Xun
Thank you so much Adis! This code works for me!
Hi Adis,
There still seems to be some issues with the caption download url.
I'm trying to apply your sample code on this caption url(https://sph.hosted.panopto.com/Panopto/Pages/Transcription/GenerateSRT.ashx?id=437f5f12-2777-41e9-96dc-af81014039e3&language=English_USA), and it just returns me an empty text file.
And btw, since there are hundreds of root folders on my site. Besides moving all the folders to one folder, and retrieve that single folder, do you happen to know any api that can return me a root folder list?
Best
Hi Xun,
When you try in browser in URL it doesn't return anything, so I guess there is no captions there or we don't have access for this particular URL.
For getting list of folders maybe you can try:
https://demo.hosted.panopto.com/Panopto/Api/Docs/index.html#/Folders/Folders_GetChildFolders
To get a list of all top level folders, use an empty GUID (00000000-0000-0000-0000-000000000000)
I hope this helps. Please let me know if you have any other questions.
Thanks,
Adis
Hi Adis,
You are right, and some caption urls need access token. Therefore, I write some code like this:
I'm using this code to call the api, and it succeed. However when I replace the api url with caption url, it still returns me empty string. And on the other hand, I can see the caption in Chrome where I'm using my notebook in Chrome.
I also tried the following code which is to add the access_token to the header of the request, but it still returns me an empty file
Hi Xun,
I believe I've answered your question in the post you created.
I hope this helps. Please let me know if you have any other questions.
Thanks,
Asher Finkel