Skip to content

Conversation

@Twilight0
Copy link
Contributor

Can be utilized to masquerade streamlink and python installation to multiple browser possibilities.

Can be utilized to masquerade streamlink and python installation to multiple browser possibilities.
@codecov
Copy link

codecov bot commented Jun 13, 2018

Codecov Report

Merging #1794 into master will decrease coverage by 0.02%.
The diff coverage is 11.11%.

@@            Coverage Diff             @@
##           master    #1794      +/-   ##
==========================================
- Coverage   49.95%   49.92%   -0.03%     
==========================================
  Files         232      232              
  Lines       13843    13852       +9     
==========================================
+ Hits         6915     6916       +1     
- Misses       6928     6936       +8


def random_agent():

import random
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should import modules at the top, unless there is a specific reason not to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lazy imports tend to work faster and since they are needed only locally in the function that why I put them there. This is only example however because the difference will be negligible anyway.

@bastimeyer
Copy link
Member

bastimeyer commented Jun 13, 2018

I think the idea of having better UA strings is not bad, but I'm not a fan of this particular solution, as it only provides a set of statically generated UAs, which doesn't solve the issue of using Streamlink "anonymously" / "transparently". The current CHROME UA is pretty much outdated and all of Streamlink's HTTP requests using this UA can be identified pretty easily. Same would be true for this suggested approach, but for a set of static UA strings instead of one.

Having something like CHROME_LATEST that gets included during build time by some external library like fake-useragent and which changes in each Streamlink release would be much better, since those UAs are not unique to Streamlink and are based on up2date real world usage statistics. A random UA string could also be generated by using this lib, if needed.

@Twilight0
Copy link
Contributor Author

Twilight0 commented Jun 13, 2018

@bastimeyer Why add yet another dependency for build or core one when you can add a simple function like this and update manually from time to time.

@back-to
Copy link
Collaborator

back-to commented Jun 15, 2018

using random old versions makes you more unique than the latest stable version

which is exactly the opposite of what you probably wanted


https://github.com/streamlink/streamlink/blob/master/src/streamlink/plugin/api/useragents.py

the streamlink useragents should be changed once a month or so,
they are very old which means they are very unique right now.


using a dependency is maybe a bit to much for this.


python-requests/2.18.4 is currently the most used User-Agent of Streamlink,
which is fine as it's used very often but it could be also changed to Firefox or Chrome

@beardypig
Copy link
Member

It might be nice to have a few more choices - but you'd want it to be consistent across requests in the same session. We could randomly assign a default, then plugins can change it as needed.

I don't think we'd want to add fake-useragent as a dependency, but you could probably use the output file from that to update the useragents list semi-automatically. Taking the most popular version of Chrome, Firefox, Opera, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants