Answer the question
In order to leave comments, you need to log in
How to parse a link to a video in classmates?
How to get a link to a video from a page on a video in classmates (for example , ok.ru/video/41451653700 )? I did not find anything worthwhile in the html code itself. Is there some sort of algorithm? The youtube-dl script, if I'm not mistaken, somehow it parses.
Answer the question
In order to leave comments, you need to log in
The algorithm is as follows:
1. Extract the value of the attributedata-options
corresponding to the video ID from the page code, pass it through unescape , and pull it up as JSON .
Source snippet:
...
data-options="{"playerId":"VideoPopup_player_63567059965189_0","width":"491","height":"275","url":"http://st.mycdn.me/static/MegaPlayer/10-1-2/vp.swf","url11":"http://st.mycdn.me/static/MegaPlayer/10-1-2/vp11.swf","minFlashVersionNewPlayer":"11.2","wmode":"opaque","asa":true,"provider":"UPLOADED_ODKL","flashvars":{"saveLastPlayingTimeFrom":"30","bigLike":"1","autoplayEnabled":"1","locale":"ru","noChannel":"1","noExpandInFeed":"0","enabledLocalStorage":"1","minCacheTime":"120","isLayer":"1","metadataUrl":"http://ok.ru%2Fdk%3Fcmd%3DvideoPlayerMetadata%26mid%3D29019278039%26mtId=63567059965189-0%26aid=529301710341","partition":"4","translations":"{\"region_restriction\":\"Видео недоступно для региона\",\"upload\":\"Добавить видео\",\"exit_wide\":\"Обычный размер\",\"ultra\":\"2160\",\"subscribed\":\"Вы подписаны\",\"next_video\":\"Следующее видео\",\"unsubscribe\":\"Отписаться\",\"exit_fs\":\"Свернуть\",\"skip_adv\":\"Пропустить рекламу\",\"you\":\"Вы\",\"mute\":\"Выключить звук\",\"lowest\":\"240\",\"watch_ok\":\"Смотреть в Одноклассниках\",\"very_big_embed_size\":\"Очень большой\",\"copy_link\":\"Копировать ссылку\",\"adv_sec\":\"сек\",\"sd\":\"480\",\"low\":\"360\",\"adv_label\":\"Реклама\",\"share\":\"Ссылка\",\"not_found\":\"Видео не найдено\",\"quality_title\":\"Качество\",\"big_embed_size\":\"Большой\",\"quad\":\"1440\",\"link_to_video\":\"Ссылка на видео\",\"copy_link_time\":\"Скопировать URL с привязкой ко времени\",\"auto\":\"Авто\",\"decode\":\"Браузер не поддерживает воспроизведение видео\",\"small_embed_size\":\"Маленький\",\"quality_change\":\"Изменить качество\",\"external_not_found\":\"Видео на внешнем ресурсе недоступно\",\"other_embed_size\":\"Другой размер\",\"like\":\"Класс!\",\"replay\":\"Смотреть ещё\",\"adv\":\"Вы сможете пропустить рекламу через\",\"full\":\"1080\",\"copy_code\":\"Скопировать код\",\"link\":\"Ссылка\",\"network\":\"Ошибка соединения\",\"and\":\"и\",\"unmute\":\"Включить звук\",\"enter_wide\":\"Широкий экран\",\"subscribe\":\"Подписаться\",\"mobile\":\"144\",\"enter_fs\":\"На весь экран\",\"normal_embed_size\":\"Средний\",\"link_to_html_code\":\"HTML-код\",\"compilation\":\"Канал:\",\"hd\":\"720\"}","location":"AutoplayLayerMovieRBlock/anonymMain/anonym","preferHd":"1","hideExpand":"0","noLikeButton":"1","maxCachePartOfDuration":"10","isAnonym":"1","noUpload":"1","adLogic":"15,0,3,14400"},"noFlashText":"Для воспроизведения видео вам необходимо \u003Ca class=\"totalwhite mt-5 visible\" href=\"http://www.adobe.com/go/getflashplayer\" target=\"_blank\"\u003Eустановить Adobe Flash Player\u003C/a\u003E","liveUnstartedText":"Трансляция начнётся через","liveEndedText":"Трансляция завершена","poster":"http://vdp.mycdn.me/getImage?id=39435897559\u0026idx=7\u0026thumbType=32","isExternalPlayer":false,"isHtml5Player":false}"
...
d['flashvars']['metadata']
, but there is d['flashvars']['metadataUrl']
(for example, as for this video ), then you need to separately extract JSON with metadata by the metadataUrl link. videos
, several formats with different quality....
"videos":[{"name":"mobile","url":"http://217.20.153.79/?sig=2cd2ecf161b04e022ed586eb0b11fd417b6a4831\u0026ct=0\u0026urls=217.20.157.204%3B217.20.145.41\u0026expires=1441378063103\u0026clientType=0\u0026id=39435897559\u0026type=4","seekSchema":3},{"name":"lowest","url":"http://217.20.153.79/?sig=171cee4f29e74b25c3d2f4806b7d78909b320e77\u0026ct=0\u0026urls=217.20.157.204%3B217.20.145.41\u0026expires=1441378063103\u0026clientType=0\u0026id=39435897559\u0026type=0","seekSchema":3},{"name":"low","url":"http://217.20.153.79/?sig=d689c9fabffd4a49739254d4fec4f1dc42f1b4a3\u0026ct=0\u0026urls=217.20.157.204%3B217.20.145.41\u0026expires=1441378063103\u0026clientType=0\u0026id=39435897559\u0026type=1","seekSchema":3}]
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question