Skip to content

Instantly share code, notes, and snippets.

@qzane
Last active May 14, 2018 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qzane/611126e1200b8b65cffe061da0d75282 to your computer and use it in GitHub Desktop.
Save qzane/611126e1200b8b65cffe061da0d75282 to your computer and use it in GitHub Desktop.
Kaizo_Trap.py
"""
Created on May 14 2018
@author: qzane
"""
import os,sys
import requests
from lxml import etree
MOVIE0 = r'https://www.youtube.com/watch?v=lIES3ii-IOg'
ANNOTATIONS = r'https://www.youtube.com/annotations_invideo?features=0&legacy=1&video_id=%s'
XPATH_ANNOTATIONS = r'//url'
XPATH_ANNOTATIONS1 = r'./@value'
XPATH_TIME = r'./ancestor::annotation/segment//@t'
XPATH_TITLE = r'//title/text()'
SCREEN3 = ['48', '65', '61', '76', '65', '6e', '20', '2630', '0a', '0a', '45', '61', '72', '74', '68', '20', '2637', '0a', '0a', '46', '69', '72', '65', '20', '2632', '0a', '0a', '57', '61', '74', '65', '72', '20', '2635', '0a', '0a', '6f', '65', '71', '58', '75', '65', '59', '41', '56', '53', '38', '0a', '0a', '2191', '2192', '20', '2193', '2192', '20', '2193', '2190', '20', '2191', '2190', '0a', '0a', '48', '61', '6c', '66', '20', '77', '61', '79', '20', '74', '68', '65', '72', '65', '20', '3a', '5d']
SCREEN4 = ""#todo: finish this
def get_vid(url):
tmp = url.split('/')
for i in tmp:
if i.startswith('watch?'):
pos1 = i.find('v=')
pos2 = i.find('&', pos1)
pos3 = i.find('#', pos1)
if pos2 == -1:
pos2 = len(i)
if pos3 == -1:
pos3 = len(i)
pos2 = min(pos2, pos3)
vid = i[pos1+2:pos2]
return vid
raise(Exception("no vod found"))
def get_annotations(url):
vid = get_vid(url)
nurl = ANNOTATIONS%vid
q = requests.get(nurl)
w = q.content
e = etree.HTML(w)
r = e.xpath(XPATH_ANNOTATIONS)
res = []
for i in r:
tmp1 = i.xpath(XPATH_ANNOTATIONS1)
tmp2 = i.xpath(XPATH_TIME)
if len(tmp1) >= 1 and len(tmp2) >= 1 and tmp1[0].startswith(r'https://www.youtube.com/'):
res.append((tmp1[0],tmp2[0]))
return tuple(res)
def get_title(url):
q = requests.get(url)
w = q.content.decode('utf-8')
e = etree.HTML(w)
res = e.xpath(XPATH_TITLE)
return res[0]
ALL = set()
def main(url):
print()
sys.stdout.flush()
vid = get_vid(url)
ALL.add(vid)
annotations = get_annotations(url)
res = []
for i in annotations:
vid = get_vid(i[0])
print(vid,end=' ')
sys.stdout.flush()
tmp = get_title(i[0])
if 'の罠' in tmp:
res.append((i,tmp))
for i in res:
vid = get_vid(i[0][0])
if not vid in ALL:
print()
print()
print(i[0])
print(i[1])
sys.stdout.flush()
main(i[0][0])
return res
if __name__ == '__main__':
main(MOVIE0)
for i in SCREEN3:
print(chr(int(i, 16)), end='')
print()
main(r'https://www.youtube.com/watch?v=oeqXueYAVS8')
print()
print("Movie5: WkvC3ppWMd4")
#answer: https://imgur.com/a/Z1xSl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment