Repository: ytdl-org/youtube-dl

Issue:
The Pluralsight video subtitles are missing the first phrase (cut off)
## 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 that [x])
- Use *Preview* tab to see how your issue will actually look like

---

### Make sure you are using the *latest* version: run `youtube-dl --version` and ensure your version is *2016.11.02*. 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 **2016.11.02**

### Before submitting an *issue* make sure you have:
- [x] At least skimmed through [README](https://github.com/rg3/youtube-dl/blob/master/README.md) and **most notably** [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

### What is the purpose of your *issue*?
- [x] Bug report (encountered problems with youtube-dl)
- [ ] Site support request (request for adding support for a new site)
- [ ] Feature request (request for a new functionality)
- [ ] Question
- [ ] Other

---

The problem was encountered on several videos from Pluralsight coures. First of all I download complete courses, by if I download the single video the problem stays. 
```
youtube-dl.exe -u username -p password -i -v --all-subs -o "%(playlist_title)s (by %(creator)s)/%(chapter_number)s. %(chapter)s/%(playlist_index)s - %(title)s.%(ext)s" "https://app.pluralsight.com/player?course=domain-driven-design-in-practice&author=vladimir-khorikov&name=domain-driven-design-in-practice-m1&clip=0&mode=live" 
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-u', 'PRIVATE', '-p', 'PRIVATE', '-i', '-v', '--all-subs', '-o', '%(playlist_title)s (by %(creator)s)/%(chapter_number)s. %(chapter
)s/%(playlist_index)s - %(title)s.%(ext)s', 'https://app.pluralsight.com/player?course=domain-driven-design-in-practice&author=vladimir-khorikov&name=domain-dri
ven-design-in-practice-m1&clip=0&mode=live']
[debug] Encodings: locale cp1251, fs mbcs, out cp1251, pref cp1251
[debug] youtube-dl version 2016.11.02
[debug] Python version 3.4.4 - Windows-7-6.1.7601-SP1
[debug] exe versions: none
[debug] Proxy map: {}
[pluralsight] Downloading login page
[pluralsight] Logging in as username
[pluralsight] domain-driven-design-in-practice-m1-0: Downloading JSON metadata
[pluralsight] domain-driven-design-in-practice-m1-0: Downloading mp4-high-widescreen viewclip JSON
[pluralsight] domain-driven-design-in-practice-m1-0: Waiting for 2 seconds to avoid throttling
[pluralsight] domain-driven-design-in-practice-m1-0: Downloading captions JSON
[info] Writing video subtitles to: NA (by vladimir-khorikov)\NA. NA\NA - Introduction - Getting Started.en.srt
[debug] Invoking downloader on 'http://vid20.pluralsight.com/clip-videos/vladimir-khorikov/domain-driven-design-in-practice-m1/domain-driven-design-in-practice-m1-01/1280x720mp4/20160121175752.mp4?DL7IPDlpH8_Ij-xA-JoOTZRnIRSIAsnTspRGuZJRsq6QikqUvQnp6amw0Hu7T174oouPZM4IKIYhrXozutZEO5ILnLQmPyhRFXr71xpXYwynA0MFQkt9Yvp8L6ETOP-3yJUCQgEW_Rex73TzknCw7swwAQs7zBKc0n3Uf9X24YsfcqWzGqPTrmD1d1Te8ci2TJREc66haQ3CZa5jlScKS6Nl6-BiVcfVYpgcFxwvQRA12WFg8RzdE-bdgGZntt0F5ISt8377'
[download] Destination: NA (by vladimir-khorikov)\NA. NA\NA - Introduction - Getting Started.mp4

[download]   0.1% of 1.86MiB at Unknown speed ETA Unknown ETA
[download]   0.2% of 1.86MiB at Unknown speed ETA Unknown ETA
[download]   0.4% of 1.86MiB at Unknown speed ETA Unknown ETA
[download]   0.8% of 1.86MiB at  7.32MiB/s ETA 00:00         
[download]   1.6% of 1.86MiB at 15.14MiB/s ETA 00:00         
[download]   3.3% of 1.86MiB at  2.37MiB/s ETA 00:00         
[download]   6.7% of 1.86MiB at  2.43MiB/s ETA 00:00         
[download]  13.4% of 1.86MiB at  3.04MiB/s ETA 00:00         
[download]  26.8% of 1.86MiB at  3.72MiB/s ETA 00:00         
[download]  53.6% of 1.86MiB at  4.67MiB/s ETA 00:00         
[download] 100.0% of 1.86MiB at  5.65MiB/s ETA 00:00         
[download] 100% of 1.86MiB in 00:00
```
The issue is that subtitles are not full. The first phrase is cut off, which usually starts from 00:00:00. So the subtitles only start from the second phrase at 06:00:00

```
1
00:00:06,000 --> 00:00:12,000
and you struggle to understand how to start applying its concepts in your own project?

2
00:00:12,000 --> 00:00:18,000
Or maybe you had a hard time to combine them with other well-known practices, such as unit testing
...
```



Discussion:
Can you watch complete subtitles in browser in the first place?

Yes, of course.

It still not yet fixed.
This first phrase cutoff only occurs if `"displayTimeOffset"` is `0.0`

Because the code on #L174:
https://github.com/rg3/youtube-dl/blob/c94427dd60f9836e3752077977cae3b4d0da47d1/youtube_dl/extractor/pluralsight.py#L173-L177

calls the method `dict_get` and this method returns `None`, because `d["displayTimeOffset"]` produces value `0.0`, i.e. falsy value; and thus the subtitle line is skipped.

Issue can be fixed with a modified call to `dict_get` on #L174

    float_or_none(dict_get(current, TIME_OFFSET_KEYS, skip_false_values=False)),

But I don't know if it breaks some other use cases.
I noticed, that this issue is tagged with "cant-reproduce" and "account-needed".

In fact, this issue: first phrase (when it starts at offset 0) is skipped when doing conversion from json to srt; can be reproduced without an account and with a "free" course overview video, for example, with this: https://app.pluralsight.com/player?name=python-getting-started-m0&clip=0&course=python-getting-started&author=bo-milanovich

Example file: [captions.json.txt](https://github.com/rg3/youtube-dl/files/1584344/captions.json.txt)

Resolving patch:
diff --git a/youtube_dl/extractor/pluralsight.py b/youtube_dl/extractor/pluralsight.py
--- a/youtube_dl/extractor/pluralsight.py
+++ b/youtube_dl/extractor/pluralsight.py
@@ -171,12 +171,12 @@ def _convert_subtitles(duration, subs):
         for num, current in enumerate(subs):
             current = subs[num]
             start, text = (
-                float_or_none(dict_get(current, TIME_OFFSET_KEYS)),
+                float_or_none(dict_get(current, TIME_OFFSET_KEYS, skip_false_values=False)),
                 dict_get(current, TEXT_KEYS))
             if start is None or text is None:
                 continue
             end = duration if num == len(subs) - 1 else float_or_none(
-                dict_get(subs[num + 1], TIME_OFFSET_KEYS))
+                dict_get(subs[num + 1], TIME_OFFSET_KEYS, skip_false_values=False))
             if end is None:
                 continue
             srt += os.linesep.join(


Test patch: