4 from .common
import InfoExtractor
5 from ..utils
import int_or_none
, parse_qs
, traverse_obj
8 class LastFMPlaylistBaseIE(InfoExtractor
):
9 def _entries(self
, url
, playlist_id
):
10 single_page
= traverse_obj(parse_qs(url
), ('page', -1, {int_or_none}
))
11 for page
in itertools
.count(single_page
or 1):
12 webpage
= self
._download
_webpage
(
13 url
, playlist_id
, f
'Downloading page {page}', query
={'page': page
})
14 videos
= re
.findall(r
'data-youtube-url="([^"]+)"', webpage
)
16 if single_page
or not videos
:
19 def _real_extract(self
, url
):
20 playlist_id
= self
._match
_id
(url
)
21 return self
.playlist_from_matches(self
._entries
(url
, playlist_id
), playlist_id
, ie
='Youtube')
24 class LastFMPlaylistIE(LastFMPlaylistBaseIE
):
25 _VALID_URL
= r
'https?://(?:www\.)?last\.fm/(music|tag)/(?P<id>[^/]+)(?:/[^/]+)?/?(?:[?#]|$)'
27 'url': 'https://www.last.fm/music/Oasis/(What%27s+the+Story)+Morning+Glory%3F',
31 'playlist_mincount': 11,
33 'url': 'https://www.last.fm/music/Oasis',
34 'only_matching': True,
36 'url': 'https://www.last.fm/music/Oasis/',
37 'only_matching': True,
39 'url': 'https://www.last.fm/music/Oasis?top_tracks_date_preset=ALL#top-tracks',
40 'only_matching': True,
42 'url': 'https://www.last.fm/music/Oasis/+tracks',
43 'only_matching': True,
45 'url': 'https://www.last.fm/music/Oasis/+tracks?page=2',
46 'only_matching': True,
48 'url': 'https://www.last.fm/music/Oasis/+tracks?date_preset=LAST_90_DAYS#top-tracks',
49 'only_matching': True,
51 'url': 'https://www.last.fm/tag/rock',
52 'only_matching': True,
54 'url': 'https://www.last.fm/tag/rock/tracks',
55 'only_matching': True,
59 class LastFMUserIE(LastFMPlaylistBaseIE
):
60 _VALID_URL
= r
'https?://(?:www\.)?last\.fm/user/[^/]+/playlists/(?P<id>[^/#?]+)'
62 'url': 'https://www.last.fm/user/mehq/playlists/12319471',
68 'url': 'https://www.last.fm/user/naamloos1/playlists/12543760',
72 'playlist_mincount': 80,
74 'url': 'https://www.last.fm/user/naamloos1/playlists/12543760?page=3',
82 class LastFMIE(InfoExtractor
):
83 _VALID_URL
= r
'https?://(?:www\.)?last\.fm/music(?:/[^/]+){2}/(?P<id>[^/#?]+)'
85 'url': 'https://www.last.fm/music/Oasis/_/Wonderwall',
86 'md5': '9c4a70c2e84c03d54fe24229b9e13b7b',
90 'title': 'Oasis - Wonderwall (Official Video)',
91 'thumbnail': r
're:^https?://i.ytimg.com/.*\.jpg$',
92 'description': 'md5:0848669853c10687cc28e88b5756738f',
94 'uploader_id': 'oasisinetofficial',
95 'upload_date': '20080207',
96 'album': '(What\'s The Story) Morning Glory? (Remastered)',
97 'track': 'Wonderwall (Remastered)',
98 'channel_id': 'UCUDVBtnOQi4c7E8jebpjc9Q',
100 'live_status': 'not_live',
101 'channel_url': 'https://www.youtube.com/channel/UCUDVBtnOQi4c7E8jebpjc9Q',
104 'uploader_url': 're:^https?://www.youtube.com/user/oasisinetofficial',
106 'alt_title': 'Wonderwall (Remastered)',
109 'channel_follower_count': int,
110 'categories': ['Music'],
111 'availability': 'public',
113 'playable_in_embed': True,
116 'add_ie': ['Youtube'],
118 'url': 'https://www.last.fm/music/Oasis/_/Don%27t+Look+Back+In+Anger+-+Remastered/',
119 'only_matching': True,
121 'url': 'https://www.last.fm/music/Guns+N%27+Roses/_/Sweet+Child+o%27+Mine',
122 'only_matching': True,
125 def _real_extract(self
, url
):
126 video_id
= self
._match
_id
(url
)
127 webpage
= self
._download
_webpage
(url
, video_id
)
128 player_url
= self
._search
_regex
(r
'(?s)class="header-new-playlink"\s+href="([^"]+)"', webpage
, 'player_url')
129 return self
.url_result(player_url
, 'Youtube')