[letv] Correct regular expressions and fix a typo
[youtube-dl] / youtube_dl / extractor / letv.py
index 246556316c95922de4bb130d76b04ecb8bfe16b3..ba8126f75e36d92c61086bbc7c57de1b11ed0b77 100644 (file)
@@ -1,35 +1,36 @@
 # coding: utf-8
 from __future__ import unicode_literals
 
+import base64
 import datetime
+import hashlib
 import re
 import time
-import base64
-import hashlib
 
 from .common import InfoExtractor
 from ..compat import (
-    compat_urllib_parse,
     compat_ord,
     compat_str,
+    compat_urllib_parse,
 )
 from ..utils import (
     determine_ext,
+    encode_data_uri,
     ExtractorError,
+    int_or_none,
+    orderedSet,
     parse_iso8601,
     sanitized_Request,
-    int_or_none,
     str_or_none,
-    encode_data_uri,
     url_basename,
 )
 
 
 class LetvIE(InfoExtractor):
     IE_DESC = '乐视网'
-    _VALID_URL = r'http://www\.le\.com/ptv/vplay/(?P<id>\d+).html'
+    _VALID_URL = r'http://www\.le\.com/ptv/vplay/(?P<id>\d+)\.html'
 
-    _URL_TEMPLATE = r'http://www.le.com/ptv/vplay/%s.html'
+    _URL_TEMPLATE = 'http://www.le.com/ptv/vplay/%s.html'
 
     _TESTS = [{
         'url': 'http://www.le.com/ptv/vplay/22005890.html',
@@ -195,7 +196,7 @@ class LetvIE(InfoExtractor):
 
 
 class LetvTvIE(InfoExtractor):
-    _VALID_URL = r'http://www.le.com/tv/(?P<id>\d+).html'
+    _VALID_URL = r'http://www\.le\.com/tv/(?P<id>\d+)\.html'
     _TESTS = [{
         'url': 'http://www.le.com/tv/46177.html',
         'info_dict': {
@@ -211,8 +212,8 @@ class LetvTvIE(InfoExtractor):
         page = self._download_webpage(url, playlist_id)
 
         # Currently old domain names are still used in playlists
-        media_ids = list(set(re.findall(
-            r'http://www.letv.com/ptv/vplay/(\d+).html', page)))
+        media_ids = orderedSet(re.findall(
+            r'http://www\.letv\.com/ptv/vplay/(\d+)\.html', page))
         entries = [self.url_result(LetvIE._URL_TEMPLATE % media_id, ie='Letv')
                    for media_id in media_ids]
 
@@ -225,7 +226,7 @@ class LetvTvIE(InfoExtractor):
 
 
 class LetvPlaylistIE(LetvTvIE):
-    _VALID_URL = r'http://tv.le.com/[a-z]+/(?P<id>[a-z]+)/index.s?html'
+    _VALID_URL = r'http://tv\.le\.com/[a-z]+/(?P<id>[a-z]+)/index\.s?html'
     _TESTS = [{
         'url': 'http://tv.le.com/izt/wuzetian/index.html',
         'info_dict': {