{"id":15562726,"url":"https://github.com/sonsongithub/youtubegetvideoinfoapiparser","last_synced_at":"2025-04-23T23:13:57.107Z","repository":{"id":56930195,"uuid":"55026461","full_name":"sonsongithub/YouTubeGetVideoInfoAPIParser","owner":"sonsongithub","description":"Swift Library to parse YouTube streaming data from get_video_info API.","archived":false,"fork":false,"pushed_at":"2018-04-19T16:24:52.000Z","size":65,"stargazers_count":18,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T23:13:51.668Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sonsongithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-30T02:37:51.000Z","updated_at":"2023-07-04T04:29:14.000Z","dependencies_parsed_at":"2022-08-21T00:01:09.169Z","dependency_job_id":null,"html_url":"https://github.com/sonsongithub/YouTubeGetVideoInfoAPIParser","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2FYouTubeGetVideoInfoAPIParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2FYouTubeGetVideoInfoAPIParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2FYouTubeGetVideoInfoAPIParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonsongithub%2FYouTubeGetVideoInfoAPIParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sonsongithub","download_url":"https://codeload.github.com/sonsongithub/YouTubeGetVideoInfoAPIParser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528879,"owners_count":21445518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T16:16:05.536Z","updated_at":"2025-04-23T23:13:57.080Z","avatar_url":"https://github.com/sonsongithub.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Version](http://img.shields.io/cocoapods/v/YouTubeStreamingURLParser.svg?style=flat)](http://cocoadocs.org/docsets/YouTubeStreamingURLParser)\n[![License](https://img.shields.io/cocoapods/l/YouTubeStreamingURLParser.svg?style=flat)](http://cocoadocs.org/docsets/YouTubeStreamingURLParser)\n[![Platform](https://img.shields.io/cocoapods/p/YouTubeStreamingURLParser.svg?style=flat)](http://cocoadocs.org/docsets/YouTubeStreamingURLParser)\n\n# YouTubeStreamingURLParser\n\n\n## Overview\nSwift Library to parse YouTube streaming data from `get_video_info` API. \n\nYou have to extract the raw media streaming URL of a YouTube movie when you want to play it using AVFoundation. For example, following code does not work.\n\n```\n// This code DOES NOT work.\nlet youtubeUrl = \"https://www.youtube.com/watch?v=ROEIKn8OsGU\"\nif let url = URL(string: youtubeUrl) {\n    let item = AVPlayerItem(url: url)\n    let player = AVPlayer(playerItem: item)\n    ....\n}\n```\n\nYou have to download a movie information via `get_video_info` API, `https://www.youtube.com/get_video_info?video_id=XXXXXXXXXXXXX`,  before playing the movie.\nWhile, downloading and parsing the information is very boaring.\nYouTubeStreamingURLParser helps you to do it.\n\n## YouTube streaming information\n\nThis API returns a streaming information with CGI parameter style.\n\n```\ntoken=\u003cvalue\u003e\u0026idpj=\u003cvalue\u003e\u0026as_launched_in_country=\u003cvalue\u003e\u0026iurlmq=\u003cvalue\u003e\u0026\nview_count=\u003cvalue\u003e\u0026iurl=\u003cvalue\u003e\u0026iv_invideo_url=\u003cvalue\u003e\u0026thumbnail_url=\u003cvalue\u003e\u0026\nsffb=\u003cvalue\u003e\u0026cc_font=\u003cvalue\u003e\u0026keywords=\u003cvalue\u003e\u0026fade_out_duration_milliseconds=\u003cvalue\u003e\u0026\nad_module=\u003cvalue\u003e\u0026csi_page_type=\u003cvalue\u003e\u0026shortform=\u003cvalue\u003e\u0026c=\u003cvalue\u003e\u0026\nallowed_ads=\u003cvalue\u003e\u0026timestamp=\u003cvalue\u003e\u0026plid=\u003cvalue\u003e\u0026title=\u003cvalue\u003e\u0026\nallow_html5_ads=\u003cvalue\u003e\u0026probe_url=\u003cvalue\u003e\u0026afv=\u003cvalue\u003e\u0026midroll_prefetch_size=\u003cvalue\u003e\u0026\naccount_playback_token=\u003cvalue\u003e\u0026adsense_video_doc_id=\u003cvalue\u003e\u0026iurlsd=\u003cvalue\u003e\u0026\nof=\u003cvalue\u003e\u0026caption_tracks=\u003cvalue\u003e\u0026watermark=\u003cvalue\u003e\u0026use_cipher_signature=\u003cvalue\u003e\u0026\ndbp=\u003cvalue\u003e\u0026default_audio_track_index=\u003cvalue\u003e\u0026midroll_freqcap=\u003cvalue\u003e\u0026\nexcluded_ads=\u003cvalue\u003e\u0026ad_flags=\u003cvalue\u003e\u0026allow_ratings=\u003cvalue\u003e\u0026no_get_video_log=\u003cvalue\u003e\u0026\ncver=\u003cvalue\u003e\u0026cc_asr=\u003cvalue\u003e\u0026iurlmaxres=\u003cvalue\u003e\u0026caption_translation_languages=\u003cvalue\u003e\u0026\niv_load_policy=\u003cvalue\u003e\u0026fade_in_duration_milliseconds=\u003cvalue\u003e\u0026video_verticals=\u003cvalue\u003e\u0026\nptchn=\u003cvalue\u003e\u0026oid=\u003cvalue\u003e\u0026iurlhq=\u003cvalue\u003e\u0026gut_tag=\u003cvalue\u003e\u0026\napply_fade_on_midrolls=\u003cvalue\u003e\u0026instream_long=\u003cvalue\u003e\u0026adaptive_fmts=\u003cvalue\u003e\u0026\ndashmpd=\u003cvalue\u003e\u0026cid=\u003cvalue\u003e\u0026muted=\u003cvalue\u003e\u0026subtitles_xlb=\u003cvalue\u003e\u0026\ncore_dbp=\u003cvalue\u003e\u0026cc3_module=\u003cvalue\u003e\u0026cl=\u003cvalue\u003e\u0026storyboard_spec=\u003cvalue\u003e\u0026\nptk=\u003cvalue\u003e\u0026iv_allow_in_place_switch=\u003cvalue\u003e\u0026vm=\u003cvalue\u003e\u0026video_id=\u003cvalue\u003e\u0026\nad_device=\u003cvalue\u003e\u0026url_encoded_fmt_stream_map=\u003cvalue\u003e\u0026iv_module=\u003cvalue\u003e\u0026\nad_logging_flag=\u003cvalue\u003e\u0026author=\u003cvalue\u003e\u0026pltype=\u003cvalue\u003e\u0026fade_in_start_milliseconds=\u003cvalue\u003e\u0026\nmpvid=\u003cvalue\u003e\u0026caption_audio_tracks=\u003cvalue\u003e\u0026cc_module=\u003cvalue\u003e\u0026\ncc_fonts_url=\u003cvalue\u003e\u0026ad_slots=\u003cvalue\u003e\u0026has_cc=\u003cvalue\u003e\u0026show_content_thumbnail=\u003cvalue\u003e\u0026\nldpj=\u003cvalue\u003e\u0026iv3_module=\u003cvalue\u003e\u0026length_seconds=\u003cvalue\u003e\u0026tmi=\u003cvalue\u003e\u0026\nhl=\u003cvalue\u003e\u0026ypc_ad_indicator=\u003cvalue\u003e\u0026ttsurl=\u003cvalue\u003e\u0026enabled_engage_types=\u003cvalue\u003e\u0026\nis_listed=\u003cvalue\u003e\u0026ucid=\u003cvalue\u003e\u0026eventid=\u003cvalue\u003e\u0026fade_out_start_milliseconds=\u003cvalue\u003e\u0026\nfmt_list=\u003cvalue\u003e\u0026avg_rating=\u003cvalue\u003e\u0026fexp=\u003cvalue\u003e\u0026tag_for_child_directed=\u003cvalue\u003e\u0026\nloeid=\u003cvalue\u003e\u0026afv_ad_tag=\u003cvalue\u003e\u0026allow_embed=\u003cvalue\u003e\u0026enablecsi=\u003cvalue\u003e\u0026status=ok\n```\n\n## Streaming URL in \"url\\_encoded\\_fmt\\_stream\\_map\"\n\nAn entry whose key is \"url\\_encoded\\_fmt\\_stream\\_map\" includes CGI parameter style text which is comma seperated. This parameter often has one more than entries. Each entry involves the movie's video type, raw media streaming URL, size and so on.\n\nIf you want to get the movie of raw streaming URL, \n\n```\n\u003centry\u003e,\u003centry\u003e,\u003centry\u003e,\u003centry\u003e,\u003centry\u003e,\u003centry\u003e,\u003centry\u003e\n```\n\n```\nfallback_host=tc.v17.cache7.googlevideo.com\u0026\nitag=22\u0026\nurl=\u003cURL\u003e\u0026\ntype=video%2Fmp4%3B+codecs%3D%22avc1.64001F%2C+mp4a.40.2%22\u0026\nquality=hd720\n```\n\n## How to use\n\n```\nlet infoURL = NSURL(string:\"https://www.youtube.com/get_video_info?video_id=\\(youtubeContentID)\") {\nlet request = NSMutableURLRequest(URL: infoURL)\nlet session = NSURLSession(configuration: sessionConfiguration)\nlet task = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -\u003e Void in\n    if let error = error {\n        print(error)\n    } else if let data = data, result = NSString(data: data, encoding: NSUTF8StringEncoding) as? String {\n        // Pattern 1\n        // Get streaming map directly\n\t    let maps = FormatStreamMapFromString(result)\n\t    if let map = maps.first {\n\t        print(map.url)\n\t    }\n\t    // Pattern 2\n\t    // Get streaming informaton\n\t    // You can access stream map from this object, too.\n\t    let streaming = YouTubeStreamingFromString(result)\n\t    print(streaming.title)\n    }\n})\ntask.resume()\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonsongithub%2Fyoutubegetvideoinfoapiparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonsongithub%2Fyoutubegetvideoinfoapiparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonsongithub%2Fyoutubegetvideoinfoapiparser/lists"}