1

我正在制作一个下载 snapchat 故事的程序。和这个:

base64.b64decode(snap['media_iv']))

收到错误Error: Incorrect padding

实际的 media_iv 是:GhcakENDGbTNY6GzE1AV3w==


from __future__ import print_function

import os.path
import sys
from getpass import getpass
import base64
from pprint import pprint

from docopt import docopt
from Tkinter import *

from pysnap import get_file_extension, Snapchat

def printsnaps():
    s = Snapchat()
    s.login(u.get(), p.get())
    for snap in s.get_friend_stories():
        pprint(snap)
        path = snap["id"]
        data = s.get_story_blob(snap['media_id'],
            base64.b64decode(snap['media_key']),
            base64.b64decode(snap['media_iv']))
        if data is None:
            continue
        with (openpath, 'wb') as f:
            f.write(data)
top = Tk()
u = StringVar()
p = StringVar()
user = Entry(top, text="usermame", textvariable=u)
user.pack()
pswd = Entry(top, text="password", textvariable=p)
pswd.pack()
logb = Button(top, text="login", width = 15, command=printsnaps)
logb.pack()

top.mainloop()

解决方案:教程错误,不需要解码

4

1 回答 1

1

尝试使用字符串继承的解码方法:

str(snap['media_iv']).decode('base64')

我试过解码它,但它解码成一堆二进制废话,这在 SnapChat 的情况下不应该发生。也许,您给定的值不正确。

于 2015-01-17T14:36:43.680 回答