Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest youtube extractor doesn't work as in previous youtube-dl 2020.06.06 version #25706

Closed
radiolondra opened this issue Jun 17, 2020 · 0 comments
Closed

Comments

@radiolondra
Copy link

@radiolondra radiolondra commented Jun 17, 2020

Ubuntu 3.7
Youtube-DL 2020.06.16.1

Before this new Youtube-DL version 2020.06.16.1, using YTDL 2020.06.06 version the following piece of code worked fine, reporting 20 videos per query:

class ThreadClass(threading.Thread):

    def __init__(self, thread_id, name, query, page, callback):
        threading.Thread.__init__(self)
        self.thread_id = thread_id
        self.name = name
        self.callback = callback
        # self.query = query
        self.page = page
        self.query = "https://www.youtube.com/results?search_query=" + query + "&sp=CAMSAhAB&page=" + str(self.page)

    def run(self):
        # clear the scroll view
        app = MDApp.get_running_app()
        app.root.ids.md_results.clear_widgets()

        with youtube_dl.YoutubeDL(
                {
                    "forcejson": True,
                    # "dump_single_json": True,
                    "simulate": True,
                    "logger": SearchResultsCatcher(),
                    "default_search": "ytsearch",
                    # 'progress_hooks': [my_hook],
                }
        ) as ydl:
            ydl.download([self.query])

        self.callback()


class SearchResultsCatcher(object):

    def __init__(self):
        object.__init__(self)

    def debug(self, msg):
        if msg.strip()[0] == "{":
            msg = msg.replace('\\r', '').replace('\\n', '')
            j = json.loads(msg)

            clean_desc = j['description'].replace('"', ' ')
            clean_title = j['title'].replace('"', ' ')

            """
            format_str = ''
            for vid in j["formats"]:
                if vid['vcodec'] != "none" and vid['acodec'] != "none":
                    format_str = format_str + \
                        '{"videoext": "' + vid['ext'] + '",' + \
                        '"filesize": "' + str(vid['filesize']) + '",' + \
                        '"format": ' + vid['format'] + '",' + \
                        '"videourl": ' + vid['url'] + '}'

            if format_str != '':
                format_str = format_str.replace('}', '},')
                format_str = format_str[:-1]

            format_str = '"videos":[' + format_str
            format_str = format_str + ']},'
            """
            app = MDApp.get_running_app()

            id = j['id']
            title = clean_title
            thumb = j['thumbnail']
            description = clean_desc
            views = '{:,}'.format(j['view_count'])
            url = j['webpage_url']

            s = ItemDrawer(image=thumb,
                           title=title,
                           views='Views: ' + views,
                           description=description,
                           url=url,
                           alt_text="Watch on YOUTUBE")
            app.root.ids.md_results.add_widget(s)

    def warning(self, msg):
        pass

    def error(self, msg):
        pass

With the new Youtube-DL version 2020.06.16.1, the previous code doesn't work anymore, reporting ZERO videos.

[youtube:search_url] marooned: Downloading webpage
[download] Downloading playlist: marooned
[youtube:search_url] playlist marooned: Downloading 0 videos
[download] Finished downloading playlist: marooned

The query passed to obtain this result (0 videos) was a semplified version of the normally used query, without order filter (&sp=CAMSAhAB) and page number (&page=1):
https://www.youtube.com/results?search_query=marooned

Please refer to issue #25560

How can I solve this problem? What have I to change in my code to have the same result as I had before the new Youtube-DL 2020.06.16.1 release?

@dstftw dstftw closed this Jun 17, 2020
@dstftw dstftw added the duplicate label Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.