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

Likes and Dislikes both return as None. #25977

Closed
ghost opened this issue Jul 12, 2020 · 11 comments
Closed

Likes and Dislikes both return as None. #25977

ghost opened this issue Jul 12, 2020 · 11 comments
Labels

Comments

@ghost
Copy link

ghost commented Jul 12, 2020

Checklist

  • [x ] I'm asking a question
  • [x ] I've looked through the README and FAQ for similar questions
  • [x ] I've searched the bugtracker for similar questions including closed ones

Question

WRITE QUESTION HERE
When attempting to get info from a video, like_count and dislike_count both return as None.
Output of a program to get info from a video:
Views : 159370 Likes : None Dislikes : None Length : 90

@ghost ghost added the question label Jul 12, 2020
@nastia-diaphan
Copy link

nastia-diaphan commented Jul 12, 2020

This is a new bug that affect probably all YT videos. It started 4 days ago and concerns metadata like #25945 and #25937 that remain unsolved since 4 days

@RomanEmelyanov
Copy link

Try to use this patch for file youtube.py:

def _extract_count(count_name):
            return str_to_int(self._search_regex(
                r'([0-9,]+) %ss"}}' # this line fixed
                % re.escape(count_name),
                video_webpage, count_name, default=None))

@nastia-diaphan
Copy link

Try to use this patch for file youtube.py:

def _extract_count(count_name):
            return str_to_int(self._search_regex(
                r'([0-9,]+) %ss"}}' # this line fixed
                % re.escape(count_name),
                video_webpage, count_name, default=None))

short and it work. Thank you RomanEmelyanov

I will be happy if you solve this way #25945

The div is of class "reason"
<div class="reason style-scope yt-player-error-message-renderer">This video has been removed for violating YouTube's Terms of Service.</div>

@Marques-Desenv
Copy link

Marques-Desenv commented Jul 13, 2020

Try to use this patch for file youtube.py:

def _extract_count(count_name):
            return str_to_int(self._search_regex(
                r'([0-9,]+) %ss"}}' # this line fixed
                % re.escape(count_name),
                video_webpage, count_name, default=None))

Thanks for replaying this, helped a lot!

@Marques-Desenv
Copy link

Marques-Desenv commented Jul 13, 2020

The comment_count has the same problem, it always give 0 as output. Do you have a patch for this?

@RomanEmelyanov
Copy link

Try to use this patch for file youtube.py:

def _extract_count(count_name):
            return str_to_int(self._search_regex(
                r'([0-9,]+) %ss"}}' # this line fixed
                % re.escape(count_name),
                video_webpage, count_name, default=None))

short and it work. Thank you RomanEmelyanov

I will be happy if you solve this way #25945

The div is of class "reason"
<div class="reason style-scope yt-player-error-message-renderer">This video has been removed for violating YouTube's Terms of Service.</div>

Just replace this function in file youtube.py:

        def extract_unavailable_message():
            return self._html_search_regex(
                r',"reason":"(.*?)"',
                video_webpage, 'unavailable message', default=None)

@nastia-diaphan
Copy link

Try to use this patch for file youtube.py:

def _extract_count(count_name):
            return str_to_int(self._search_regex(
                r'([0-9,]+) %ss"}}' # this line fixed
                % re.escape(count_name),
                video_webpage, count_name, default=None))

short and it work. Thank you RomanEmelyanov
I will be happy if you solve this way #25945
The div is of class "reason"
<div class="reason style-scope yt-player-error-message-renderer">This video has been removed for violating YouTube's Terms of Service.</div>

Just replace this function in file youtube.py:

        def extract_unavailable_message():
            return self._html_search_regex(
                r',"reason":"(.*?)"',
                video_webpage, 'unavailable message', default=None)

Marvelous, you are my savior RomanEmelyanov. One more time, it work and your code look so simple.

One question: why a new version of youtube-dl is so long to come after you have published a solution ?

@GlassedSilver
Copy link

GlassedSilver commented Jul 13, 2020

Try to use this patch for file youtube.py:

def _extract_count(count_name):
            return str_to_int(self._search_regex(
                r'([0-9,]+) %ss"}}' # this line fixed
                % re.escape(count_name),
                video_webpage, count_name, default=None))

short and it work. Thank you RomanEmelyanov
I will be happy if you solve this way #25945
The div is of class "reason"
<div class="reason style-scope yt-player-error-message-renderer">This video has been removed for violating YouTube's Terms of Service.</div>

Just replace this function in file youtube.py:

        def extract_unavailable_message():
            return self._html_search_regex(
                r',"reason":"(.*?)"',
                video_webpage, 'unavailable message', default=None)

Marvelous, you are my savior RomanEmelyanov. One more time, it work and your code look so simple.

One question: why a new version of youtube-dl is so long to come after you have published a solution ?

Taking a wild guess here, it may be because no maintainer of the repo who'd be authorized to merge the PRs has seen the tickets or experienced this bug in their own usage yet.

The urgency of this issue is of course pretty drastic, but also means we experience the lack of an official fix as even slower I take it. :)

I mean, it's not like it's hard to "bury" important things in this repo:

Anmerkung 2020-07-13 234159

😛

@nastia-diaphan
Copy link

nastia-diaphan commented Jul 13, 2020

Try to use this patch for file youtube.py:

def _extract_count(count_name):
            return str_to_int(self._search_regex(
                r'([0-9,]+) %ss"}}' # this line fixed
                % re.escape(count_name),
                video_webpage, count_name, default=None))

short and it work. Thank you RomanEmelyanov
I will be happy if you solve this way #25945
The div is of class "reason"
<div class="reason style-scope yt-player-error-message-renderer">This video has been removed for violating YouTube's Terms of Service.</div>

Just replace this function in file youtube.py:

        def extract_unavailable_message():
            return self._html_search_regex(
                r',"reason":"(.*?)"',
                video_webpage, 'unavailable message', default=None)

Thanks again RomanEmelyanov, but your code need some more work.
Some unavailable messages are dispatched in two fields. by example for duplicated video.
Here is the video_webpage fragment
..."playabilityStatus":{"status":"ERROR","reason":"Video unavailable","errorScreen":{"playerErrorMessageRenderer":{"subreason":{"simpleText":"This video is a duplicate of another YouTube video"},"reason":{"simpleText":"Video unavailable"}...
and of course, the only information your code return is "Video unavailable"

I have tried to solve it by myself, but in vain. Here is my code

       def extract_unavailable_message():
           messages = []
           for tag in ('"reason":', '"subreason":\{"simpleText":'):
               msg = self._html_search_regex(
                   r',{tag}"(.*?)"'.format(tag=tag),
                   video_webpage, 'unavailable message', default=None)
               if msg:
                   messages.append(msg)
           if messages:
               return '\n'.join(messages)

Unfortunately this code return only "Video unavailable" just as yours. I'm lost.

even this one doesn't work at all

      def extract_unavailable_message():
            return self._html_search_regex(
                r',"simpleText":"(.*?)"',
                video_webpage, 'unavailable message', default=None)

really, I'm lost in the dark

@RomanEmelyanov
Copy link

RomanEmelyanov commented Jul 14, 2020

Code not perfect but works for me:

        def extract_unavailable_message():
            reason = self._html_search_regex(
                r'"subreason":{"runs":(\[.*?\])',
                video_webpage, 'unavailable message', default=None)
            try:
                reason_array = json.loads(reason); reason = ''
                for item in reason_array:
                    reason += item['text']
            except:
                pass
            if reason is None:
                reason = self._html_search_regex(
                    r'"subreason":{"simpleText":"(.*?)"',
                    video_webpage, 'unavailable message', default=None)
            if reason is None:
                reason = self._html_search_regex(
                    r',"reason":"(.*?)"',
                    video_webpage, 'unavailable message', default=None)
            return reason```

@nastia-diaphan
Copy link

nastia-diaphan commented Jul 14, 2020

Code not perfect but works for me:

        def extract_unavailable_message():
            reason = self._html_search_regex(
                r'"subreason":{"runs":(\[.*?\])',
                video_webpage, 'unavailable message', default=None)
            try:
                reason_array = json.loads(reason); reason = ''
                for item in reason_array:
                    reason += item['text']
            except:
                pass
            if reason is None:
                reason = self._html_search_regex(
                    r'"subreason":{"simpleText":"(.*?)"',
                    video_webpage, 'unavailable message', default=None)
            if reason is None:
                reason = self._html_search_regex(
                    r',"reason":"(.*?)"',
                    video_webpage, 'unavailable message', default=None)
            return reason```

Your code work for me too (before you edited it), Thank you RomanEmelyanov

I rewrote it like this to keep the carriage return of current youtube-dl code

        def extract_unavailable_message():
            reason = self._html_search_regex(
                    r',"reason":"(.*?)"',
                    video_webpage, 'unavailable message', default=None)
            subreason = self._html_search_regex(
                    r'"subreason":{"simpleText":"(.*?)"',
                    video_webpage, 'unavailable message', default=None)
            if reason:
                if subreason:
                    reason = reason + '\n' + subreason
                return reason

Not a nice code, but readable and it work like expected... for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants