Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/tarangplus.py (Python)

Code before:
            'id': 'trailer',
            'title': 'Trailer',
        },
        'playlist_mincount': 57,
    }, {
        'url': 'https://tarangplus.in/latest-songs/all',
        'info_dict': {
            'id': 'latest-songs',
            'title': 'Latest Songs',
        },
        'playlist_mincount': 46,
    }, {
        'url': 'https://tarangplus.in/premium-serials-episodes/all',
        'info_dict': {
            'id': 'premium-serials-episodes',
            'title': 'Primetime Latest Episodes',
        },
        'playlist_mincount': 100,
    }]

    def _entries(self, webpage):
        items = get_elements_html_by_class('item', webpage)
        for item in items:
            a_elem = get_element_text_and_html_by_tag('a', item)[1]
            url = urljoin(self._BASE_URL, extract_attributes(a_elem)['href'])
            yield self.url_result(url, TarangPlusVideoIE)

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)
        title = get_element_by_id('al_title', webpage)
        entries = self._entries(webpage)
        return self.playlist_result(entries, display_id, title)


Review comment (refactor):
```suggestion
        for url_path in traverse_obj(webpage, (
            {find_elements(cls='item')}, ...,
            {find_elements(tag='a', attr='href', value='/.+', html=True, regex=True)},
            ..., {extract_attributes}, 'href',
        )):
            yield self.url_result(urljoin(self._BASE_URL, url_path), TarangPlusVideoIE)
```
this might be a good use case for `playlist_from_matches` too, but not necessary

Code after:
class TarangPlusPlaylistIE(TarangPlusBaseIE):
    IE_NAME = 'tarangplus:playlist'
    _VALID_URL = r'https?://(?:www\.)?tarangplus\.in/(?P<id>[^#?/]+)/all/?(?:$|[?#])'
    _TESTS = [{
        'url': 'https://tarangplus.in/chhota-jaga/all',
        'info_dict': {
            'id': 'chhota-jaga',
            'title': 'Chhota Jaga',
        },
        'playlist_mincount': 33,
    }, {
        'url': 'https://tarangplus.in/kids-yali-show/all',
        'info_dict': {
            'id': 'kids-yali-show',
            'title': 'Yali',
        },
        'playlist_mincount': 10,
    }, {
        'url': 'https://tarangplus.in/trailer/all',
        'info_dict': {
            'id': 'trailer',
            'title': 'Trailer',
        },
        'playlist_mincount': 57,
    }, {
        'url': 'https://tarangplus.in/latest-songs/all',
        'info_dict': {
            'id': 'latest-songs',
            'title': 'Latest Songs',
        },
        'playlist_mincount': 46,
    }, {
        'url': 'https://tarangplus.in/premium-serials-episodes/all',
        'info_dict': {
            'id': 'premium-serials-episodes',
            'title': 'Primetime Latest Episodes',
        },
        'playlist_mincount': 100,
    }]

    def _entries(self, webpage):
        for url_path in traverse_obj(webpage, (
            {find_elements(cls='item')}, ...,
            {find_elements(tag='a', attr='href', value='/.+', html=True, regex=True)},
            ..., {extract_attributes}, 'href',
        )):
            yield self.url_result(urljoin(self._BASE_URL, url_path), TarangPlusVideoIE)

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)