Cách lấy subtitle trên Udemy

Xin chào mọi người,

Hiện tại mình đang cần lấy các file subtitle trên trang Udemy để mang về dịch. Hiện tại thì mình đang dùng cách vào tab Network của Chrome Dev để dowload nhưng hơi mất công. Vậy thì có cách nào để dowload bằng code Javascript không mọi người nhỉ??


Mình đã thử viết một đoạn nhỏ, sử dụng $( document ).ajaxSend để bắt sự kiện khi GET file subtitle. Nhưng có vẻ không khả quan, vì khi mình chạy đoạn code đó thì web đã load hết được resource rồi :frowning:

Cảm ơn mọi người nhiều :))))

Nó lấy được rồi có nghĩa là nó cũng tạo các thẻ track bên trong thẻ video đã được tạo ra rồi chứ nhỉ. Truy vấn để lấy chúng là xong mà.

4 Likes

Thay courseID với lectureId, với phần auth của bạn vào là ok

curl 'https://www.udemy.com/api-2.0/users/me/subscribed-courses/1212032/lectures/7155758?fields\[lecture\]=asset,description,download_url,is_free,last_watched_second&fields\[asset\]=asset_type,length,stream_urls,captions,thumbnail_url,thumbnail_sprite,slides,slide_urls,download_urls'\
  -H 'Sec-Fetch-Mode: cors'\
  -H 'X-Udemy-Cache-Release: 85da887cd08c7e894eee82e5790b258b3bd02809'\
  -H 'X-Udemy-Cache-User: 24139808'\
  -H 'Authorization: Bearer sJwmr26rmzypsAVEQSd03iRFqbc3mEnUJZsIzYvG'\
  -H 'X-Udemy-Cache-Language: en'\
  -H 'X-Udemy-Cache-Brand: ::VN:en_US'\
  -H 'X-Requested-With: XMLHttpRequest'\
  -H 'X-Udemy-Cache-Logged-In: 1'\
  -H 'X-Udemy-Cache-Device: None'\
  -H 'X-Udemy-Cache-Version: 1'\
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'\
  -H 'X-Udemy-Authorization: Bearer sJwmr26rmzypsAVEQSd03iRFqbc3mEnUJZsIzYvG'\
  -H 'Accept: application/json, text/plain, */*'\
  -H 'Referer: https://www.udemy.com/python-for-finance-and-trading-algorithms/learn/lecture/7155758?start=15'\
  -H 'X-Udemy-Cache-Price-Country: VN'\
  -H 'X-Udemy-Cache-Marketplace-Country: VN'\
  -H 'X-Udemy-Cache-Campaign-Code: MASTERANYTHING'\
  --compressed

Kết quả:

{
  "_class": "lecture",
  "id": 7155758,
  "description": "",
  "is_free": true,
  "asset": {
    "_class": "asset",
    "id": 9109638,
    "asset_type": "Video",
    "length": 567,
    "captions": [
      {
        "_class": "caption",
        "id": 8551244,
        "title": "id_ID.introduction-to-quantopian.autogenerated.vtt",
        "created": "2019-02-27T14:23:18Z",
        "file_name": "2019-02-27_14-23-18-1fa88b15175d2cb80d082e261ccf9e07.vtt",
        "status": 1,
        "url": "https://c.udemycdn.com/9109638/id_ID/2019-02-27_14-23-18-1fa88b15175d2cb80d082e261ccf9e07.vtt?nva=20190812135001&response-content-disposition=attachment%3B+filename=%22id_idintroduction-to-quantopianautogenerated.vtt%22&token=0a1496e4dd16b64409ef4",
        "source": "auto",
        "locale_id": "id_ID",
        "video_label": "Indonesian [Auto]",
        "asset_id": 9109638
      },
      {
        "_class": "caption",
        "id": 7224804,
        "title": "pl_PL.introduction-to-quantopian.autogenerated.vtt",
        "created": "2018-12-13T15:22:17Z",
        "file_name": "2018-12-13_15-22-17-c590cccc0848d15c65a84ee9f242ab3e.vtt",
        "status": 1,
        "url": "https://c.udemycdn.com/9109638/pl_PL/2018-12-13_15-22-17-c590cccc0848d15c65a84ee9f242ab3e.vtt?nva=20190812135001&response-content-disposition=attachment%3B+filename=%22pl_plintroduction-to-quantopianautogenerated.vtt%22&token=0d65dd10a1bf78b1fedf6",
        "source": "auto",
        "locale_id": "pl_PL",
        "video_label": "Polish [Auto]",
        "asset_id": 9109638
      },
      {
        "_class": "caption",
        "id": 6912385,
        "title": "ro_RO.introduction-to-quantopian.autogenerated.vtt",
        "created": "2018-12-02T09:32:46Z",
        "file_name": "2018-12-02_09-32-46-8eb9de5e1e8265452f54d539606ff46b.vtt",
        "status": 1,
        "url": "https://c.udemycdn.com/9109638/ro_RO/2018-12-02_09-32-46-8eb9de5e1e8265452f54d539606ff46b.vtt?nva=20190812135001&response-content-disposition=attachment%3B+filename=%22ro_rointroduction-to-quantopianautogenerated.vtt%22&token=005a401b3b09aecc4b2cb",
        "source": "auto",
        "locale_id": "ro_RO",
        "video_label": "Romanian [Auto]",
        "asset_id": 9109638
      },
      {
        "_class": "caption",
        "id": 4433184,
        "title": "pt_PT.introduction-to-quantopian.autogenerated.vtt",
        "created": "2018-03-01T17:06:52Z",
        "file_name": "2018-03-01_17-06-52-baf0b59f628a42a9b43d2e671eafa0ba.vtt",
        "status": 1,
        "url": "https://c.udemycdn.com/9109638/pt_BR/2018-03-01_17-06-52-baf0b59f628a42a9b43d2e671eafa0ba.vtt?nva=20190812135001&response-content-disposition=attachment%3B+filename=%22pt_ptintroduction-to-quantopianautogenerated.vtt%22&token=06cc111a305e892907162",
        "source": "auto",
        "locale_id": "pt_BR",
        "video_label": "Portuguese [Auto]",
        "asset_id": 9109638
      },
      {
        "_class": "caption",
        "id": 4416818,
        "title": "it_IT.introduction-to-quantopian.autogenerated.vtt",
        "created": "2018-03-01T16:48:51Z",
        "file_name": "2018-03-01_16-48-51-d14181507d7266d79e99a185c1ccc7bb.vtt",
        "status": 1,
        "url": "https://c.udemycdn.com/9109638/it_IT/2018-03-01_16-48-51-d14181507d7266d79e99a185c1ccc7bb.vtt?nva=20190812135001&response-content-disposition=attachment%3B+filename=%22it_itintroduction-to-quantopianautogenerated.vtt%22&token=071e4f9c6a36cfd8014dd",
        "source": "auto",
        "locale_id": "it_IT",
        "video_label": "Italian [Auto]",
        "asset_id": 9109638
      },
      {
        "_class": "caption",
        "id": 4391738,
        "title": "ja_JP.introduction-to-quantopian.autogenerated.vtt",
        "created": "2018-03-01T16:18:39Z",
        "file_name": "2018-03-01_16-18-39-a99ab6acb8512f291cb2a039074330f8.vtt",
        "status": 1,
        "url": "https://c.udemycdn.com/9109638/ja_JP/2018-03-01_16-18-39-a99ab6acb8512f291cb2a039074330f8.vtt?nva=20190812135001&response-content-disposition=attachment%3B+filename=%22ja_jpintroduction-to-quantopianautogenerated.vtt%22&token=097336840028507b21f91",
        "source": "auto",
        "locale_id": "ja_JP",
        "video_label": "Japanese [Auto]",
        "asset_id": 9109638
      },
      {
        "_class": "caption",
        "id": 4353994,
        "title": "es_ES.introduction-to-quantopian.autogenerated.vtt",
        "created": "2018-02-27T14:12:22Z",
        "file_name": "2018-02-27_14-12-22-041661dbe713a5ebf5bf5b8dfd7cf69f.vtt",
        "status": 1,
        "url": "https://c.udemycdn.com/9109638/es_ES/2018-02-27_14-12-22-041661dbe713a5ebf5bf5b8dfd7cf69f.vtt?nva=20190812135001&response-content-disposition=attachment%3B+filename=%22es_esintroduction-to-quantopianautogenerated.vtt%22&token=083c55846790d2514ed9d",
        "source": "auto",
        "locale_id": "es_ES",
        "video_label": "Spanish [Auto]",
        "asset_id": 9109638
      },
      {
        "_class": "caption",
        "id": 585216,
        "title": "introduction-to-quantopian.autogenerated.vtt",
        "created": "2017-09-08T08:40:15Z",
        "file_name": "2017-09-08_08-40-15-af8b1b7fed65db4ed33aed9862b0997f.vtt",
        "status": 1,
        "url": "https://c.udemycdn.com/9109638/en_US/2017-09-08_08-40-15-af8b1b7fed65db4ed33aed9862b0997f.vtt?nva=20190812135001&response-content-disposition=attachment%3B+filename=%22introduction-to-quantopianautogenerated.vtt%22&token=07d4ef72086ef5c86a75f",
        "source": "auto",
        "locale_id": "en_US",
        "video_label": "English [Auto]",
        "asset_id": 9109638
      }
    ],
    "download_urls": null,
    "slide_urls": [],
    "slides": [],
    "thumbnail_url": "https://a2.udemycdn.com/2017-07-28_01-22-52-ecb506759b88b960d92f8d54f769f2df/thumb-1.jpg?nva=20190812142001&token=0464a5d4e74d1ee433a91",
    "stream_urls": {
      "Video": [
        {
          "type": "video/mp4",
          "label": "720",
          "file": "https://a2.udemycdn.com/2017-07-28_01-22-52-ecb506759b88b960d92f8d54f769f2df/WebHD_720p.mp4?nva=20190812142001&token=0af7eec6d7f113174b0c5"
        },
        {
          "type": "video/mp4",
          "label": "480",
          "file": "https://a.udemycdn.com/2017-07-28_01-22-52-ecb506759b88b960d92f8d54f769f2df/WebHD_480.mp4?nva=20190812142001&token=03e4fc44bf3e1486e4c45"
        },
        {
          "type": "video/mp4",
          "label": "360",
          "file": "https://a2.udemycdn.com/2017-07-28_01-22-52-ecb506759b88b960d92f8d54f769f2df/WebHD.mp4?nva=20190812142001&token=07b01c2b90c77b1afd50d"
        },
        {
          "type": "video/mp4",
          "label": "144",
          "file": "https://a.udemycdn.com/2017-07-28_01-22-52-ecb506759b88b960d92f8d54f769f2df/Web_144.mp4?nva=20190812142001&token=0ceb1bcfa738fc986ac8b"
        },
        {
          "type": "application/x-mpegURL",
          "file": "/assets/9109638/files/1212032/9109638/2017-07-28_01-22-52-ecb506759b88b960d92f8d54f769f2df/aa005f510334fe7cff265ec134acac3420b0.m3u8",
          "label": "Auto"
        }
      ]
    },
    "thumbnail_sprite": {
      "vtt_url": "https://a2.udemycdn.com/2017-07-28_01-22-52-ecb506759b88b960d92f8d54f769f2df/thumb-sprites.vtt?nva=20190812142001&token=016033c2155d71cbc4e49",
      "img_url": "https://a2.udemycdn.com/2017-07-28_01-22-52-ecb506759b88b960d92f8d54f769f2df/thumb-sprites.jpg?nva=20190812142001&token=0a2f778c8c40f9b3324e1"
    }
  },
  "last_watched_second": null,
  "download_url": ""
}

9 Likes

Cảm ơn bạn :)) Mình làm được rồi :)))

1 Like
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?