]> jfr.im git - yt-dlp.git/blame - youtube_dlc/extractor/tmz.py
[TMZ] Add support for new page structure using JSON-LD
[yt-dlp.git] / youtube_dlc / extractor / tmz.py
CommitLineData
f0c3d729
MR
1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
5
6
7class TMZIE(InfoExtractor):
fff50711
DFRV
8 _VALID_URL = r"https?://(?:www\.)?tmz\.com/.*"
9 _TESTS = [
10 {
11 "url": "http://www.tmz.com/videos/0-cegprt2p/",
12 "info_dict": {
13 "id": "http://www.tmz.com/videos/0-cegprt2p/",
14 "ext": "mp4",
15 "title": "No Charges Against Hillary Clinton? Harvey Says It Ain't Over Yet",
16 "description": "Harvey talks about Director Comey’s decision not to prosecute Hillary Clinton.",
17 "timestamp": 1467831837,
18 "uploader": "{'@type': 'Person', 'name': 'TMZ Staff'}",
19 "upload_date": "20160706",
20 },
21 },
22 {
23 "url": "https://www.tmz.com/videos/071119-chris-morgan-women-4590005-0-zcsejvcr/",
24 "info_dict": {
25 "id": "https://www.tmz.com/videos/071119-chris-morgan-women-4590005-0-zcsejvcr/",
26 "ext": "mp4",
27 "title": "Angry Bagel Shop Guy Says He Doesn't Trust Women",
28 "description": "The enraged man who went viral for ranting about women on dating sites before getting ragdolled in a bagel shop is defending his misogyny ... he says it's women's fault in the first place.",
29 "timestamp": 1562889485,
30 "uploader": "{'@type': 'Person', 'name': 'TMZ Staff'}",
31 "upload_date": "20190711",
32 },
33 },
34 {
35 "url": "http://www.tmz.com/2015/04/19/bobby-brown-bobbi-kristina-awake-video-concert",
36 "md5": "5429c85db8bde39a473a56ca8c4c5602",
37 "info_dict": {
38 "id": "http://www.tmz.com/2015/04/19/bobby-brown-bobbi-kristina-awake-video-concert",
39 "ext": "mp4",
40 "title": "Bobby Brown Tells Crowd ... Bobbi Kristina is Awake",
41 "description": 'Bobby Brown stunned his audience during a concert Saturday night, when he told the crowd, "Bobbi is awake. She\'s watching me."',
42 "timestamp": 1429467813,
43 "uploader": "{'@type': 'Person', 'name': 'TMZ Staff'}",
44 "upload_date": "20150419",
45 },
46 },
47 {
48 "url": "http://www.tmz.com/2015/09/19/patti-labelle-concert-fan-stripping-kicked-out-nicki-minaj/",
49 "info_dict": {
50 "id": "http://www.tmz.com/2015/09/19/patti-labelle-concert-fan-stripping-kicked-out-nicki-minaj/",
51 "ext": "mp4",
52 "title": "Patti LaBelle -- Goes Nuclear On Stripping Fan",
53 "description": "Patti LaBelle made it known loud and clear last night ... NO "
54 "ONE gets on her stage and strips down.",
55 "timestamp": 1442683746,
56 "uploader": "{'@type': 'Person', 'name': 'TMZ Staff'}",
57 "upload_date": "20150919",
58 },
59 },
60 {
61 "url": "http://www.tmz.com/2016/01/28/adam-silver-sting-drake-blake-griffin/",
62 "info_dict": {
63 "id": "http://www.tmz.com/2016/01/28/adam-silver-sting-drake-blake-griffin/",
64 "ext": "mp4",
65 "title": "NBA's Adam Silver -- Blake Griffin's a Great Guy ... He'll Learn from This",
66 "description": "Two pretty parts of this video with NBA Commish Adam Silver.",
67 "timestamp": 1454010989,
68 "uploader": "{'@type': 'Person', 'name': 'TMZ Staff'}",
69 "upload_date": "20160128",
70 },
71 },
72 {
73 "url": "http://www.tmz.com/2016/10/27/donald-trump-star-vandal-arrested-james-otis/",
74 "info_dict": {
75 "id": "http://www.tmz.com/2016/10/27/donald-trump-star-vandal-arrested-james-otis/",
76 "ext": "mp4",
77 "title": "Trump Star Vandal -- I'm Not Afraid of Donald or the Cops!",
78 "description": "James Otis is the the guy who took a pickaxe to Donald Trump's star on the Walk of Fame, and he tells TMZ .. he's ready and willing to go to jail for the crime.",
79 "timestamp": 1477500095,
80 "uploader": "{'@type': 'Person', 'name': 'TMZ Staff'}",
81 "upload_date": "20161026",
82 },
83 },
84 {
85 "url": "https://www.tmz.com/videos/2020-10-31-103120-beverly-hills-protest-4878209/",
86 "info_dict": {
87 "id": "https://www.tmz.com/videos/2020-10-31-103120-beverly-hills-protest-4878209/",
88 "ext": "mp4",
89 "title": "Cops Use Billy Clubs Against Pro-Trump and Anti-Fascist "
90 "Demonstrators",
91 "description": "Beverly Hills may be an omen of what's coming next week, "
92 "because things got crazy on the streets and cops started "
93 "swinging their billy clubs at both Anti-Fascist and Pro-Trump "
94 "demonstrators.",
95 "timestamp": 1604182772,
96 "uploader": "{'@type': 'Person', 'name': 'TMZ Staff'}",
97 "upload_date": "20201031",
98 },
99 },
100 ]
f0c3d729
MR
101
102 def _real_extract(self, url):
fff50711
DFRV
103 webpage = self._download_webpage(url, url)
104 jsonld = self._search_json_ld(webpage, url)
105 if id not in jsonld:
106 jsonld["id"] = url
107 return jsonld