mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
improve youtube collector/parser
This commit is contained in:
parent
621471a7cb
commit
228f71708b
32
bin/mtag/res/yt-ipr.user.js
Normal file
32
bin/mtag/res/yt-ipr.user.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name youtube-playerdata-hub
|
||||||
|
// @match https://youtube.com/*
|
||||||
|
// @match https://*.youtube.com/*
|
||||||
|
// @version 1.0
|
||||||
|
// @grant GM_addStyle
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
var sent = {};
|
||||||
|
function send(txt) {
|
||||||
|
if (sent[txt])
|
||||||
|
return;
|
||||||
|
|
||||||
|
fetch('https://127.0.0.1:3923/playerdata?_=' + Date.now(), { method: "PUT", body: txt });
|
||||||
|
console.log('[yt-ipr] yeet %d bytes', txt.length);
|
||||||
|
sent[txt] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function collect() {
|
||||||
|
setTimeout(collect, 60 * 1000);
|
||||||
|
var pd = document.querySelector('ytd-watch-flexy');
|
||||||
|
if (pd)
|
||||||
|
send(JSON.stringify(pd.playerData));
|
||||||
|
}
|
||||||
|
setTimeout(collect, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
var scr = document.createElement('script');
|
||||||
|
scr.textContent = '(' + main.toString() + ')();';
|
||||||
|
(document.head || document.getElementsByTagName('head')[0]).appendChild(scr);
|
||||||
|
console.log('[yt-ipr] a');
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import gzip
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -14,19 +15,16 @@ example usage:
|
||||||
:c,mtp=yt-id,yt-title,yt-author,yt-channel,yt-views,yt-private,yt-expires=bin/mtag/yt-ipr.py
|
:c,mtp=yt-id,yt-title,yt-author,yt-channel,yt-views,yt-private,yt-expires=bin/mtag/yt-ipr.py
|
||||||
:c,mte=yt-id,yt-title,yt-author,yt-channel,yt-views,yt-private,yt-expires
|
:c,mte=yt-id,yt-title,yt-author,yt-channel,yt-views,yt-private,yt-expires
|
||||||
|
|
||||||
quick userscript to push them across:
|
see res/yt-ipr.user.js for the example userscript to go with this
|
||||||
console.log('a');
|
|
||||||
setTimeout(function() {
|
|
||||||
for (var scr of document.querySelectorAll('script[nonce]'))
|
|
||||||
if (scr.innerHTML.indexOf('manifest.googlevideo.com/api/manifest')>0)
|
|
||||||
fetch('https://127.0.0.1:3923/playerdata', {method:"PUT", body: scr.innerHTML});
|
|
||||||
}, 10*1000);
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with open(sys.argv[1], "r", encoding="utf-8") as f:
|
try:
|
||||||
|
with gzip.open(sys.argv[1], "rt", encoding="utf-8", errors="replace") as f:
|
||||||
|
txt = f.read()
|
||||||
|
except:
|
||||||
|
with open(sys.argv[1], "r", encoding="utf-8", errors="replace") as f:
|
||||||
txt = f.read()
|
txt = f.read()
|
||||||
|
|
||||||
txt = "{" + txt.split("{", 1)[1]
|
txt = "{" + txt.split("{", 1)[1]
|
||||||
|
|
Loading…
Reference in a new issue