get_song: fix signatureTimestamp (#196)
This commit is contained in:
parent
8c4b857f5c
commit
5d59a09751
2 changed files with 12 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ import json
|
|||
from http.cookies import SimpleCookie
|
||||
from hashlib import sha1
|
||||
import time
|
||||
from datetime import date
|
||||
from functools import wraps
|
||||
import locale
|
||||
from ytmusicapi.constants import *
|
||||
|
|
@ -102,6 +103,10 @@ def get_authorization(auth):
|
|||
return "SAPISIDHASH " + unix_timestamp + "_" + sha_1.hexdigest()
|
||||
|
||||
|
||||
def get_datestamp():
|
||||
return (date.today() - date.fromtimestamp(0)).days
|
||||
|
||||
|
||||
def to_int(string):
|
||||
number_string = string.split(' ')[0]
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -542,11 +542,13 @@ class BrowsingMixin:
|
|||
|
||||
return album
|
||||
|
||||
def get_song(self, videoId: str) -> Dict:
|
||||
def get_song(self, videoId: str, signatureTimestamp: int = None) -> Dict:
|
||||
"""
|
||||
Returns metadata and streaming information about a song or video.
|
||||
|
||||
:param videoId: Video id
|
||||
:param signatureTimestamp: Provide the current YouTube signatureTimestamp.
|
||||
If not provided a default value will be used, which might result in invalid streaming URLs
|
||||
:return: Dictionary with song metadata.
|
||||
|
||||
Example::
|
||||
|
|
@ -702,10 +704,13 @@ class BrowsingMixin:
|
|||
|
||||
"""
|
||||
endpoint = 'player'
|
||||
if not signatureTimestamp:
|
||||
signatureTimestamp = get_datestamp() - 1
|
||||
|
||||
params = {
|
||||
"playbackContext": {
|
||||
"contentPlaybackContext": {
|
||||
"signatureTimestamp": 18766
|
||||
"signatureTimestamp": signatureTimestamp
|
||||
}
|
||||
},
|
||||
"video_id": videoId
|
||||
|
|
|
|||
Loading…
Reference in a new issue