Repository: youtube-dl
Issue: Site support request: ViuTV (viu.tv)
Labels: geo-restricted

## Please follow the guide below

- You will be asked some questions and requested to provide some information, please read them **carefully** and answer honestly
- Put an `x` into all the boxes [ ] relevant to your *issue* (like this: `[x]`)
- Use the *Preview* tab to see what your issue will actually look like

---

### Make sure you are using the *latest* version: run `youtube-dl --version` and ensure your version is *2018.08.04*. If it's not, read [this FAQ entry](https://github.com/rg3/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl) and update. Issues with outdated version will be rejected.
- [x] I've **verified** and **I assure** that I'm running youtube-dl **2018.08.04**

### Before submitting an *issue* make sure you have:
- [x] At least skimmed through the [README](https://github.com/rg3/youtube-dl/blob/master/README.md), **most notably** the [FAQ](https://github.com/rg3/youtube-dl#faq) and [BUGS](https://github.com/rg3/youtube-dl#bugs) sections
- [x] [Searched](https://github.com/rg3/youtube-dl/search?type=Issues) the bugtracker for similar issues including closed ones
- [x] Checked that provided video/audio/playlist URLs (if any) are alive and playable in a browser

### What is the purpose of your *issue*?
- [ ] Bug report (encountered problems with youtube-dl)
- [x] Site support request (request for adding support for a new site)
- [ ] Feature request (request for a new functionality)
- [ ] Question
- [ ] Other

---

### The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your *issue*

---

### If the purpose of this *issue* is a *bug report*, *site support request* or you are not completely sure provide the full verbose output as follows:

Add the `-v` flag to **your command line** you run youtube-dl with (`youtube-dl -v <your command line>`), copy the **whole** output and insert it here. It should look similar to one below (replace it with **your** log inserted between triple ```):

```
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'http://viu.tv/encore/amanchu-advance/amanchu-advancee1mau-goh-ha-tin-maan-seung-yue-go-baak-dik-si']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.08.04
[debug] Python version 3.7.0 (CPython) - Linux-4.17.13-arch1-1-ARCH-x86_64-with-arch-Arch-Linux
[debug] exe versions: ffmpeg n4.0.2, ffprobe n4.0.2, rtmpdump 2.4
[debug] Proxy map: {}
[generic] amanchu-advancee1mau-goh-ha-tin-maan-seung-yue-go-baak-dik-si: Requesting header
WARNING: Falling back on generic information extractor.
[generic] amanchu-advancee1mau-goh-ha-tin-maan-seung-yue-go-baak-dik-si: Downloading webpage
[generic] amanchu-advancee1mau-goh-ha-tin-maan-seung-yue-go-baak-dik-si: Extracting information
ERROR: Unsupported URL: http://viu.tv/encore/amanchu-advance/amanchu-advancee1mau-goh-ha-tin-maan-seung-yue-go-baak-dik-si
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 792, in extract_info
    ie_result = ie.extract(url)
  File "/usr/lib/python3.7/site-packages/youtube_dl/extractor/common.py", line 502, in extract
    ie_result = self._real_extract(url)
  File "/usr/lib/python3.7/site-packages/youtube_dl/extractor/generic.py", line 3274, in _real_extract
    raise UnsupportedError(url)
youtube_dl.utils.UnsupportedError: Unsupported URL: http://viu.tv/encore/amanchu-advance/amanchu-advancee1mau-goh-ha-tin-maan-seung-yue-go-baak-dik-si
```

---

### If the purpose of this *issue* is a *site support request* please provide all kinds of example URLs support for which should be included (replace following example URLs by **yours**):
- Single video: http://viu.tv/encore/amanchu-advance/amanchu-advancee1mau-goh-ha-tin-maan-seung-yue-go-baak-dik-si
- Single video: http://viu.tv/encore/re-zero-starting-life-in-another-world/re-zero--starting-life-in-another-worlde14ming-wai-juet-mong-dik-jat-beng
- Playlist: (Not applicable)

Note that **youtube-dl does not support sites dedicated to [copyright infringement](https://github.com/rg3/youtube-dl#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free)**. In order for site support request to be accepted all provided example URLs should not violate any copyrights.

---

### Description of your *issue*, suggested solution and other information

Explanation of your *issue* in arbitrary form goes here. Please make sure the [description is worded well enough to be understood](https://github.com/rg3/youtube-dl#is-the-description-of-the-issue-itself-sufficient). Provide as much context and examples as possible.
If work on your *issue* requires account credentials please provide them or explain how one can obtain them.

1. ViuTV is a legitimate TV channel in Hong Kong. Not to be confused with the over-the-top (OTT) video service, Viu.
2. For some programmes, one can visit the website and watch recent episodes for free without an account. (i.e. No need to log in)
3. **The programmes can only be watched in Hong Kong. The website will check the IP address.**
3. The above example URLs should be valid until 2018/08/25. For those programmes, an episode is available for 14 days from the original air date.
4. The URLs seem to be in the following format: `http://viu.tv/encore/<programme name>/<programe name>e<episode number><episode title in Cantonese Romanization a.k.a. Cantonese Pinyin>`
5. Using various tools, such as uBlock Origin, I can see that the browser accesses some `.m3u8` URLs when loading the page. Some `.m3u8` URLs have a token parameter. (e.g. http://219.76.112.178/session/p8-5-6bd5ef84f75-103b5d391edc78b/hls/vodcp20/201808090592104/201808090592104.m3u8?token=a286766801b1a06d909fc654407b37a6_1533995750_1533981650)
6. By using `ffmpeg` on the `.m3u8` URLs, the episode can be downloaded. You may find an excerpt of `ffmpeg` output below.
*Note that there are two audio streams in the example - one is Japanese dub and another is Cantonese dub. The command in the example does not download both audio streams - only one audio stream will be selected.*
7. For the same session, subtitles are available at `http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104-TRD.srt`.
```$ ffmpeg -i 'http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104.m3u8?token=499cc7923bef342a897c3b352abf68ef_1534009994_1533995894' -c copy output.mkv
ffmpeg version n4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.1.1 (GCC) 20180531
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
[hls,applehttp @ 0x556f43e6ba40] Opening 'http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer5_vod.m3u8' for reading
[http @ 0x556f43e83180] Opening 'http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer1_vod.m3u8' for reading
[http @ 0x556f43e83180] Opening 'http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer2_vod.m3u8' for reading
[http @ 0x556f43e83180] Opening 'http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer3_vod.m3u8' for reading
[http @ 0x556f43e83180] Opening 'http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer4_vod.m3u8' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'https://wstreamks.now.com/hls/vodcp20/vodcp20.key' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer5/4452_Period1/segment0.aac' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'https://wstreamks.now.com/hls/vodcp20/vodcp20.key' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer1/4452_Period1/segment0.ts' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'https://wstreamks.now.com/hls/vodcp20/vodcp20.key' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer2/4452_Period1/segment0.ts' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'https://wstreamks.now.com/hls/vodcp20/vodcp20.key' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer3/4452_Period1/segment0.ts' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'https://wstreamks.now.com/hls/vodcp20/vodcp20.key' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer4/4452_Period1/segment0.ts' for reading
Input #0, hls,applehttp, from 'http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104.m3u8?token=499cc7923bef342a897c3b352abf68ef_1534009994_1533995894':
  Duration: 00:23:02.00, start: 0.127989, bitrate: 0 kb/s
  Program 0 
    Metadata:
      variant_bitrate : 339789
    Stream #0:0(A2): Audio: aac (HE-AAC), 48000 Hz, stereo, fltp, 92 kb/s
    Metadata:
      id3v2_priv.com.apple.streaming.transportStreamTimestamp: \x00\x00\x00\x00\x00\x00,\xff
      comment         : Audio 2
    Stream #0:1: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 426x240, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      variant_bitrate : 339789
    Stream #0:2(A1): Audio: aac (HE-AAC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp (default)
    Metadata:
      variant_bitrate : 339789
      comment         : Audio 1
  Program 1 
    Metadata:
      variant_bitrate : 853700
    Stream #0:0(A2): Audio: aac (HE-AAC), 48000 Hz, stereo, fltp, 92 kb/s
    Metadata:
      id3v2_priv.com.apple.streaming.transportStreamTimestamp: \x00\x00\x00\x00\x00\x00,\xff
      comment         : Audio 2
    Stream #0:3: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 854x480, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      variant_bitrate : 853700
    Stream #0:4(A1): Audio: aac (HE-AAC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp (default)
    Metadata:
      variant_bitrate : 853700
      comment         : Audio 1
  Program 2 
    Metadata:
      variant_bitrate : 1675777
    Stream #0:0(A2): Audio: aac (HE-AAC), 48000 Hz, stereo, fltp, 92 kb/s
    Metadata:
      id3v2_priv.com.apple.streaming.transportStreamTimestamp: \x00\x00\x00\x00\x00\x00,\xff
      comment         : Audio 2
    Stream #0:5: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 1280x720, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      variant_bitrate : 1675777
    Stream #0:6(A1): Audio: aac (HE-AAC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp (default)
    Metadata:
      variant_bitrate : 1675777
      comment         : Audio 1
  Program 3 
    Metadata:
      variant_bitrate : 3116703
    Stream #0:0(A2): Audio: aac (HE-AAC), 48000 Hz, stereo, fltp, 92 kb/s
    Metadata:
      id3v2_priv.com.apple.streaming.transportStreamTimestamp: \x00\x00\x00\x00\x00\x00,\xff
      comment         : Audio 2
    Stream #0:7: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      variant_bitrate : 3116703
    Stream #0:8(A1): Audio: aac (HE-AAC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp (default)
    Metadata:
      variant_bitrate : 3116703
      comment         : Audio 1
Output #0, matroska, to 'AA_01.mkv':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Video: h264 (Main) (H264 / 0x34363248), yuv420p(tv), 1920x1080, q=2-31, 25 fps, 25 tbr, 1k tbn, 90k tbc
    Metadata:
      variant_bitrate : 3116703
    Stream #0:1(A2): Audio: aac (HE-AAC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 92 kb/s
    Metadata:
      id3v2_priv.com.apple.streaming.transportStreamTimestamp: \x00\x00\x00\x00\x00\x00,\xff
      comment         : Audio 2
Stream mapping:
  Stream #0:7 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer5/4452_Period1/segment1.aac' for reading
[hls,applehttp @ 0x556f43e6ba40] No longer receiving playlist 1
[hls,applehttp @ 0x556f43e6ba40] No longer receiving playlist 2
[hls,applehttp @ 0x556f43e6ba40] No longer receiving playlist 3
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer4/4452_Period1/segment1.ts' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer5/4452_Period1/segment2.aac' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer4/4452_Period1/segment2.ts' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer5/4452_Period1/segment3.aac' for reading
[hls,applehttp @ 0x556f43e6ba40] Opening 'crypto+http://219.76.14.67/session/p8-5-27eb10f8627-183c7b5e177af05/hls/vodcp20/201808090592104/201808090592104_Layer4/4452_Period1/segment3.ts' for reading
```