Skip to content

Instantly share code, notes, and snippets.

@Reacoder
Created July 25, 2014 05:24
Show Gist options
  • Save Reacoder/ad462024ab35d576f60e to your computer and use it in GitHub Desktop.
Save Reacoder/ad462024ab35d576f60e to your computer and use it in GitHub Desktop.
替换url 中的某个参数。
protected static String getRealPlayUrl(String playUrlWithTempSig, String sig) {
// http://r13---sn-a5m7ln7r.googlevideo.com/videoplayback?
// sparams=gcr%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&source=youtube
// &signature=74A5A84D017C326B86FBB2515BD6C00BCD85133A.E1CB6514CD41B99045FF236A3F7CF0F50F4AEC14&itag=22&key=yt5&mws=yes&gcr=cn&ms=au
// &ipbits=0&ratebypass=yes&expire=1406281956&upn=raAqucAppMU&id=o-AP5UIALOxGG5ae6zN-JNagnKvRQa_WtGXk8czf3NgFuW&mv=u&sver=3&ip=199.245.60.115
// &fexp=902408%2C924222%2C927622%2C934024%2C934030%2C941431%2C945066%2C946023&mt=1406260337&initcwndbps=1093375
String realUrl = playUrlWithTempSig.replaceFirst("signature="+"[^&]*", "signature="+sig);
System.out.println("======= realUrl ======="+realUrl);
return realUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment