]>
code.delx.au - webdl/blob - ten.py
1 from common
import grab_json
, download_hls
, Node
, append_to_qs
3 SERIES_LIST_URL
= "http://vod.ten.com.au/config/android-v2"
4 SERIES_DETAIL_URL
= "https://v.tenplay.com.au/api/videos/bcquery"
6 class TenVideoNode(Node
):
7 def __init__(self
, title
, parent
, video_url
):
8 Node
.__init
__(self
, title
, parent
)
9 self
.can_download
= True
10 self
.video_url
= video_url
13 filename
= self
.title
+ ".ts"
14 return download_hls(filename
, self
.video_url
)
16 class TenSeriesNode(Node
):
17 def __init__(self
, title
, parent
, query
, clean_name
):
18 Node
.__init
__(self
, title
, parent
)
21 self
.clean_name
= clean_name
22 self
.video_ids
= set()
24 def fill_children(self
):
25 self
.fill_children_with_query(self
.query
)
27 if "&none" not in self
.query
:
28 # Some videos are not categorised correctly, so try looking up by the cleanname as well.
29 # Only do this if they haven't tried to filter out similarly named shows.
30 self
.fill_children_with_query("&all=tv_show_group:" + self
.clean_name
)
32 def fill_children_with_query(self
, query
):
34 while page_number
< 100:
35 url
= self
.get_page_url(query
, page_number
)
43 for video_desc
in items
:
44 self
.process_video(video_desc
)
46 def get_page_url(self
, query
, page_number
):
47 return append_to_qs(SERIES_DETAIL_URL
, {
48 "command": "search_videos",
49 "all": "video_type_long_form:Full+Episode",
51 "page_number": str(page_number
),
54 def process_video(self
, video_desc
):
55 video_id
= video_desc
["id"]
56 video_url
= video_desc
["HLSURL"]
57 title
= video_desc
["name"]
59 if video_id
in self
.video_ids
:
61 self
.video_ids
.add(video_id
)
63 TenVideoNode(title
, self
, video_url
)
65 class TenRootNode(Node
):
66 def fill_children(self
):
67 doc
= grab_json(SERIES_LIST_URL
)
69 for series
in doc
["Browse TV"]["Shows"]:
70 title
= series
["title"]
71 query
= series
["query"]
72 clean_name
= series
["cleanname"]
74 TenSeriesNode(title
, self
, query
, clean_name
)
76 def fill_nodes(root_node
):
77 TenRootNode("Ten", root_node
)