<jupyter_start><jupyter_text>Get Opensubtitles data<jupyter_code>%load_ext autoreload
%autoreload 2<jupyter_output><empty_output><jupyter_text>Imports<jupyter_code>from bechdelai.data.opensubtitles import search
from bechdelai.data.opensubtitles import get_subtitle_link
from bechdelai.data.opensubtitles import download_subtitle_from_url
from bechdelai.data.opensubtitles import get_subtitles_from_movie<jupyter_output><empty_output><jupyter_text>Search<jupyter_code>movie_name = "Avatar"
language_code = "fre"
search_url = search(movie_name, language_code)
search_url
wanted_movie = 'Avatar (2009)'
search_url[wanted_movie]<jupyter_output><empty_output><jupyter_text>Get subtitle link<jupyter_code>subtitle_url = get_subtitle_link(search_url[wanted_movie])
subtitle_url<jupyter_output><empty_output><jupyter_text>Download subtitle from url<jupyter_code>res = download_subtitle_from_url(subtitle_url)
for srt in res[:5]:
    print(f"{srt.start} ==> {srt.end}")
    print(srt.text)
    print()<jupyter_output>00:00:38,873 ==> 00:00:41,166
Cloué au lit, à l'hôpital des Vétérans,

00:00:41,376 ==> 00:00:44,378
avec un grand trou au milieu de ma vie,

00:00:45,004 ==> 00:00:47,506
j'ai commencé à rêver que je volais.

00:00:48,716 ==> 00:00:50,217
J'étais libre.

00:00:53,555 ==> 00:00:57,141
Mais tôt ou tard... il faut se réveiller.<jupyter_text>get subtitles from movie  Without defined index<jupyter_code>res = get_subtitles_from_movie(movie_name, language_code, search_result_index=None)
for srt in res[:5]:
    print(f"{srt.start} ==> {srt.end}")
    print(srt.text)
    print()<jupyter_output>00:00:01,865 ==> 00:00:03,119
<i>L'eau.</i>

00:00:04,760 ==> 00:00:05,624
<i>La terre.</i>

00:00:06,880 ==> 00:00:07,856
<i>Le feu.</i>

00:00:09,526 ==> 00:00:10,449
<i>L'air.</i>

00:00:12,465 ==> 00:00:15,836
<i>Ma grand-mère
me racontait les temps anciens,</i><jupyter_text>With defined index<jupyter_code>res = get_subtitles_from_movie(movie_name, language_code, search_result_index=8)
for srt in res[:5]:
    print(f"{srt.start} ==> {srt.end}")
    print(srt.text)
    print()<jupyter_output>00:00:01,918 ==> 00:00:02,918
<i>L'eau.</i>

00:00:04,373 ==> 00:00:05,417
<i>La terre.</i>

00:00:06,089 ==> 00:00:07,089
<i>Le feu.</i>

00:00:08,463 ==> 00:00:09,463
<i>L'air.</i>

00:00:10,656 ==> 00:00:14,258
<i>Il y a longtemps,
les quatre nations vivaient en paix.</i>
StarcoderdataJupyterStructuredCleanDedup