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

[bilibili]can't download for new format #24439

Closed
kesdoputr opened this issue Mar 23, 2020 · 4 comments
Closed

[bilibili]can't download for new format #24439

kesdoputr opened this issue Mar 23, 2020 · 4 comments

Comments

@kesdoputr
Copy link

@kesdoputr kesdoputr commented Mar 23, 2020

Bilibili seems change it's video number format
The two url direct to same video
https://www.bilibili.com/video/av98307847
https://www.bilibili.com/video/BV1JE411F741

youtube-dl can't download the second link with BV start

C:\Users\k7\Desktop>youtube-dl -F https://www.bilibili.com/video/BV1JE411F741
[generic] BV1JE411F741: Requesting header
WARNING: Falling back on generic information extractor.
[generic] BV1JE411F741: Downloading webpage
[generic] BV1JE411F741: Extracting information
WARNING: [generic] BV1JE411F741: Failed to parse JSON Invalid control character
at: line 1 column 106 (char 105)
ERROR: Unsupported URL: https://www.bilibili.com/video/BV1JE411F741

C:\Users\k7\Desktop>youtube-dl -F https://www.bilibili.com/video/av98307847
[BiliBili] 98307847: Downloading webpage
[BiliBili] 98307847: Downloading video info page
[info] Available formats for 98307847:
format code extension resolution note
0 flv unknown 2.21GiB

@SekiBetu
Copy link

@SekiBetu SekiBetu commented Mar 23, 2020

eventually av-xxxxxxxx will gone

@mwx2006
Copy link

@mwx2006 mwx2006 commented Mar 23, 2020

_VALID_URL = r'https?://(?:www\.|bangumi\.|)bilibili\.(?:tv|com)/(?:video/av|anime/(?P<anime_id>\d+)/play#)(?P<id>\d+)'
_VALID_URL = r'https?://(?:www\.|bangumi\.|)bilibili\.(?:tv|com)/(?:video/BV|anime/(?P<anime_id>\d+)/play#)(?P<id>\d+)'
@GrayXu
Copy link

@GrayXu GrayXu commented Mar 23, 2020

share an AV<->BV transformation method from mcfx Zhihu

table='fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'
tr={}
for i in range(58):
	tr[table[i]]=i
s=[11,10,3,8,4,6,2,9,5,7]
xor=177451812
add=100618342136696320

def dec(x):
	r=0
	for i in range(10):
		r+=tr[x[s[i]]]*58**i
	return (r-add)^xor

def enc(x):
	x=(x^xor)+add
	r=list('BV          ')
	for i in range(10):
		r[s[i]]=table[x//58**i%58]
	return ''.join(r)

print(dec('BV17x411w7KC'))
print(dec('BV1Q541167Qg'))
print(dec('BV1mK4y1C7Bz'))
print(enc(170001))
print(enc(455017605))
print(enc(882584971))
@SekiBetu
Copy link

@SekiBetu SekiBetu commented Mar 23, 2020

share an AV<->BV transformation method from mcfx Zhihu

table='fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'
tr={}
for i in range(58):
	tr[table[i]]=i
s=[11,10,3,8,4,6,2,9,5,7]
xor=177451812
add=100618342136696320

def dec(x):
	r=0
	for i in range(10):
		r+=tr[x[s[i]]]*58**i
	return (r-add)^xor

def enc(x):
	x=(x^xor)+add
	r=list('BV          ')
	for i in range(10):
		r[s[i]]=table[x//58**i%58]
	return ''.join(r)

print(dec('BV17x411w7KC'))
print(dec('BV1Q541167Qg'))
print(dec('BV1mK4y1C7Bz'))
print(enc(170001))
print(enc(455017605))
print(enc(882584971))

no, it's not a universal solution, it only works when av number < 2^30

@dstftw dstftw closed this in b4eb08b Mar 23, 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
4 participants
You can’t perform that action at this time.