• 0 Posts
  • 778 Comments
Joined 2 years ago
cake
Cake day: July 3rd, 2023

help-circle






  • New Year’s is my favorite holiday. Just gonna chill with a friend with beer, crackers and some chess/video games. My Christmas present from my dad was to go buy some fireworks with him, so I got a bunch of stuff to do at midnight.

    Way better than Christmas or Easter or other baloney festivities. New Year’s is at least somewhat tangible even tho I do concede, it makes no difference.



  • I wrote myself a Chrome add-on that adds a context menu entry to play or download links.

    background.js
    chrome.runtime.onInstalled.addListener(() => {
    		
        chrome.contextMenus.create({
            id: "processLink",
            title: "Download as...",
            contexts: ["link"]
        });
    
        chrome.contextMenus.create({
            id: "720p",
            parentId: "processLink",
            title: "720p",
            contexts: ["link"]
        });
    
        chrome.contextMenus.create({
            id: "music",
            parentId: "processLink",
            title: "MP3",
            contexts: ["link"]
        });
    
        chrome.contextMenus.create({
            id: "maxQual",
            parentId: "processLink",
            title: "Maximum quality video",
            contexts: ["link"]
        });
    	
        chrome.contextMenus.create({
            id: "separator1",
            parentId: "processLink",
            type: "separator",
            contexts: ["link"]
        });
    
        chrome.contextMenus.create({
            id: "piQual",
            parentId: "processLink",
            title: "30 fps for RPi",
            contexts: ["link"]
        });
    	
        chrome.contextMenus.create({
            id: "separator2",
            parentId: "processLink",
            type: "separator",
            contexts: ["link"]
        });
    	
        chrome.contextMenus.create({
            id: "streamLink",
            parentId: "processLink",
            title: "Stream to VLC...",
            contexts: ["link"]
        });
    });
    
    chrome.contextMenus.onClicked.addListener((info, tab) => {
        let linkUrl = info.linkUrl;
    
        if (info.menuItemId === "720p") {
            sendLinkToNativeApp(linkUrl, "video720");
        } else if (info.menuItemId === "music") {
            sendLinkToNativeApp(linkUrl, "music");
        } else if (info.menuItemId === "maxQual") {
            sendLinkToNativeApp(linkUrl, "videomp4");
        } else if (info.menuItemId === "piQual") {
            sendLinkToNativeApp(linkUrl, "video720p30");
        } else if (info.menuItemId === "streamLink") {
            sendLinkToNativeApp(linkUrl, "stream");
        }
    });
    
    function sendLinkToNativeApp(link, action) {
        console.log("Sending link to native app with action:", action, link);
        chrome.runtime.sendNativeMessage(
            'com.example.ytlink_processor',
            { link: link, action: action },
            function(response) {
                if (chrome.runtime.lastError) {
                    console.error("Error:", chrome.runtime.lastError.message);
                } else {
                    console.log("Received response from native app:", response.output);
                }
            }
        );
    }
    
    native_host.py (chatGPT wrote this because I can't Python)
    import sys
    import subprocess
    import json
    import struct
    
    def log_to_file(message):
        with open("log.txt", "a") as log_file:
            log_file.write(message + "\n")
    
    def get_message():
        raw_length = sys.stdin.read(4)
        if len(raw_length) == 0:
            sys.exit(0)
        message_length = struct.unpack('I', raw_length)[0]
        message = sys.stdin.read(message_length)
        return json.loads(message)
    
    def send_message(message_content):
        message = json.dumps(message_content)
        sys.stdout.write(struct.pack('I', len(message)))
        sys.stdout.write(message)
        sys.stdout.flush()
    
    def process_link(link, action):
        if action == "stream":
            cmd = 'yt-dlp --stream "{}" -o - | "D:/Programme/VLC/vlc.exe" -'.format(link)
        else:
            cmd = 'yt-dlp --{} "{}"'.format(action, link)
        result = subprocess.Popen('start cmd /c "{}"'.format(cmd), shell=True)
        return result.stdout + result.stderr
    
    if __name__ == "__main__":
        message = get_message()
        link = message.get("link")
        action = message.get("action")
        if link and action:
            output = process_link(link, action)
            send_message({"output": output})
    
    

    The actions are just aliases for different qualities (old pi, so 720p60 stutters at times), audio extraction, etc.







  • If you don’t see a difference, you are already very close to the optimal correction and a subtle change in either direction is unnecessary. They will still go ahead and try fine-tuning the prescription and when you tell them that A and B are the same, they can fall back when they add another correction. A and B might currently be the same, but if you add C, A+C could be better than B+C.




  • An apartheid-loving nazi calls for the nazi party to be the savior of Germany? Never would I have guessed.

    The information, I as a not very politically interested German (understatement) have: We are holding re-elections on Feburary 23rd because the current government imploded. Basically, the rich guys’ party doesn’t want to make rich guys pay taxes and being children about it, most other parties seem desperate at this point, else they wouldn’t have challenged that much. They have never cared that much, so I have no idea what changed. The populist nazi party Musk cheers for has a lot traction because people are beyond stupid and self-centered and I fear that they will get a significant amount of votes. Maybe they don’t win outright, but they will realistically take second place. I regard everyone that considers to vote for AfD as a nazi.