- id = self._match_id(url)
- username, twid = re.match(r'([^/]+)/status/(\d+)', id).groups()
- name = username
- url = re.sub(r'https?://(m|mobile)\.', 'https://', url)
- webpage = self._download_webpage(url, 'tweet: ' + url)
- description = unescapeHTML(self._search_regex('<title>\s*(.+?)\s*</title>', webpage, 'title'))
- title = description.replace('\n', ' ')
- splitdesc = re.match(r'^(.+?)\s*on Twitter:\s* "(.+?)"$', title)
- if splitdesc:
- name, title = splitdesc.groups()
- title = re.sub(r'\s*https?://[^ ]+', '', title) # strip 'https -_t.co_BJYgOjSeGA' junk from filenames
- card_id = self._search_regex(r'["\']/i/cards/tfw/v1/(\d+)', webpage, '/i/card/...')
- card_url = 'https://twitter.com/i/cards/tfw/v1/' + card_id
- return {
- '_type': 'url_transparent',
- 'ie_key': 'TwitterCard',
- 'uploader_id': username,
- 'uploader': name,
- 'url': card_url,
+ mobj = re.match(self._VALID_URL, url)
+ user_id = mobj.group('user_id')
+ twid = mobj.group('id')
+
+ webpage = self._download_webpage(self._TEMPLATE_URL % (user_id, twid), twid)
+
+ username = remove_end(self._og_search_title(webpage), ' on Twitter')
+
+ title = description = self._og_search_description(webpage).strip('').replace('\n', ' ').strip('“”')
+
+ # strip 'https -_t.co_BJYgOjSeGA' junk from filenames
+ title = re.sub(r'\s+(https?://[^ ]+)', '', title)
+
+ info = {
+ 'uploader_id': user_id,
+ 'uploader': username,