It supports thepiratebay, nyaa, 1337x, libgen, limetorrents and rarbg

  • JamonBear@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    1
    ·
    21 hours ago

    Nice! It’s using xclip or xsel to copy magnet links, afaik it’s only working on Xorg. What is the Wayland alternative for xclip?

    • TUVIMEN@programming.devOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      21 hours ago

      You can use the --no-clipboard option to make a wrapper script that would integrate it with wl-copy.

  • krash@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    24 hours ago

    I really like this. Is it possible to have it search several sources in the future?

    • TUVIMEN@programming.devOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      19 hours ago

      Using all sources could return over 200 results for one query. This would make it hard to browse without fzf.

      Results would have to get sorted by the script and fields like date are provided in human readable format that would have to be converted with a lot of effort to sort it. Sources have also unique fields.

      Shell script is just bad to make that feature, although torge is extendable enough for you to make a wrapper script that could do it without sorting.

  • Bogus5553@lemm.ee
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 days ago

    Pretty cool. May I ask tough, what’s the reason for doing this in BASH and not in something like Python?

      • tenchiken@lemmy.dbzer0.comM
        link
        fedilink
        English
        arrow-up
        0
        ·
        3 days ago

        I’m with this… Bash runs in nearly anything without any real good chance of version conflicts.

        Why complicate things needlessly?

        • Rogue@feddit.uk
          link
          fedilink
          English
          arrow-up
          1
          ·
          3 days ago

          That’s profoundly untrue. Scripting in bash is an indescribably painful experience.

          You have absolutely no idea what version of a binary the user will be running so you’re limited to using only options that have been well established.

          I’ve never worked with python but I understand it has at least got some semblance of package management providing assurance that methods you’re calling exist, and I imagine it has some standardised mechanism for handling errors unlike bash.

          A simple example is making a GET request to an API and deserializing a JSON response if its successful, handling a timeout if the server can’t be reached or handling the HTTP status code if it’s not a 200 response.

          JS, python, Rust, C#, Java etc will all handle that simple scenario with zero effort but in bash it’s a nightmare.

          • rumba@lemmy.zip
            link
            fedilink
            English
            arrow-up
            0
            ·
            2 days ago

            So, you don’t know Python at all AND you don’t know Bash, but you feel compelled to talk about how one is so much better than the other?

            1. Python has a lot of compatibility problems, you have to roll the env system and do requirements, and if your distro doesn’t have those packages available, you can’t run the script. Then you can’t always run python 2 code in python 3.

            2. Bash has error handling and try/catch.

            3. Cross platfoming a shell script to run in ba, bash in linux, wsl and mac is fairly straight forward. Worst case, if you don’t have a specific flavor of bash installed, you can always install it. You rely on the posix compliance of the OS binaries to get the job done.

            -------Bash------
            
            #!/usr/bin/env bash
            
            API_URL="https://api.example.com/data"
            
            CONNECT_TIMEOUT=5   
            MAX_TIME=10         
            
            response=$(
              curl \
                --silent \
                --write-out "\n%{http_code}" \
                --connect-timeout "$CONNECT_TIMEOUT" \
                --max-time "$MAX_TIME" \
                "$API_URL"
            )
            
            http_body=$(echo "$response" | sed '$d')        
            http_code=$(echo "$response" | tail -n1)
            
            curl_exit_code=$?
            
            if [ $curl_exit_code -ne 0 ]; then
              echo "Error: Failed to connect or timed out (curl exit code $curl_exit_code)."
              exit 1
            fi
            
            if [ -z "$http_code" ]; then
              echo "Error: No HTTP status code received. The request may have timed out or failed."
              exit 1
            fi
            
            echo "HTTP status code: $http_code"
            
            if [ "$http_code" -eq 200 ]; then
              echo "Request successful! Parsing JSON response..."
              echo "$http_body" | jq
            else
              echo "Request failed with status code $http_code. Response body:"
              echo "$http_body"
              exit 1
            fi
            
            exit 0
            
            
            -------------Python-------------
            #!/usr/bin/env python3
            
            import requests
            import sys
            
            def main():
                # API endpoint
                API_URL = "https://api.example.com/data"
            
                # Timeout (in seconds)
                TIMEOUT = 5
            
                try:
                    # Make a GET request with a timeout
                    response = requests.get(API_URL, timeout=TIMEOUT)
            
                    # Check the HTTP status code
                    if response.status_code == 200:
                        # Parse the JSON response
                        try:
                            data = response.json()
                            print("Request successful. Here is the parsed JSON data:")
                            print(data)
                        except ValueError as e:
                            print("Error: Could not parse JSON response.", e)
                            sys.exit(1)
                    else:
                        # Handle non-200 status codes
                        print(f"Request failed with status code {response.status_code}.")
                        print("Response body:", response.text)
                        sys.exit(1)
            
                except requests.exceptions.Timeout:
                    print(f"Error: The request timed out after {TIMEOUT} seconds.")
                    sys.exit(1)
                except requests.exceptions.RequestException as e:
                    # Catch all other requests-related errors (e.g., connection error)
                    print(f"Error: An error occurred while making the request: {e}")
                    sys.exit(1)
            
            if __name__ == "__main__":
                main()
            
            
            
            
    • TUVIMEN@programming.devOP
      link
      fedilink
      arrow-up
      1
      ·
      3 days ago

      Not really bash but posix shell, the main reason is because at the time of making it i had not yet made python ffi for my html searching lib