mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-11-04 00:25:15 +00:00 
			
		
		
		
	[pornhub] Improve and simplify (closes #19135)
This commit is contained in:
		@@ -302,17 +302,12 @@ class PornHubIE(PornHubBaseIE):
 | 
				
			|||||||
        comment_count = self._extract_count(
 | 
					        comment_count = self._extract_count(
 | 
				
			||||||
            r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')
 | 
					            r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def _get_items(class_name):
 | 
					        def extract_list(meta_key):
 | 
				
			||||||
            div = self._search_regex(
 | 
					            div = self._search_regex(
 | 
				
			||||||
                r'<div class="' + class_name + '">([\S\s]+?)</div>',
 | 
					                r'(?s)<div[^>]+\bclass=["\'].*?\b%sWrapper[^>]*>(.+?)</div>'
 | 
				
			||||||
                webpage, class_name, default=None)
 | 
					                % meta_key, webpage, meta_key, default=None)
 | 
				
			||||||
            if div:
 | 
					            if div:
 | 
				
			||||||
                return [a for a in re.findall(r'<a href=[^>]+>([^<]+)', div)]
 | 
					                return re.findall(r'<a[^>]+\bhref=[^>]+>([^<]+)', div)
 | 
				
			||||||
            else:
 | 
					 | 
				
			||||||
                return None
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        categories = _get_items('categoriesWrapper')
 | 
					 | 
				
			||||||
        tags = _get_items('tagsWrapper')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
            'id': video_id,
 | 
					            'id': video_id,
 | 
				
			||||||
@@ -327,8 +322,8 @@ class PornHubIE(PornHubBaseIE):
 | 
				
			|||||||
            'comment_count': comment_count,
 | 
					            'comment_count': comment_count,
 | 
				
			||||||
            'formats': formats,
 | 
					            'formats': formats,
 | 
				
			||||||
            'age_limit': 18,
 | 
					            'age_limit': 18,
 | 
				
			||||||
            'tags': tags,
 | 
					            'tags': extract_list('tags'),
 | 
				
			||||||
            'categories': categories,
 | 
					            'categories': extract_list('categories'),
 | 
				
			||||||
            'subtitles': subtitles,
 | 
					            'subtitles': subtitles,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user