diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3dd031a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.mypy_cache +deluge_conf \ No newline at end of file diff --git a/deluge/cookie_deluge.txt b/deluge/cookie_deluge.txt new file mode 100644 index 0000000..e5ab99b --- /dev/null +++ b/deluge/cookie_deluge.txt @@ -0,0 +1,5 @@ +# Netscape HTTP Cookie File +# https://curl.se/docs/http-cookies.html +# This file was generated by libcurl! Edit at your own risk. + +localhost FALSE /json FALSE 1705130407 _session_id c04d013df838035551095d3b91e7d344d0e6411531d7cb281aa92e4703b8f4264176 diff --git a/deluge/curl.cfg b/deluge/curl.cfg new file mode 100644 index 0000000..449054c --- /dev/null +++ b/deluge/curl.cfg @@ -0,0 +1,10 @@ +request = "POST" +compressed +cookie = "cookie_deluge.txt" +cookie-jar = "cookie_deluge.txt" +header = "Content-Type: application/json" +header = "Accept: application/json" +url = "http://localhost:8112/json" +write-out = "\n" + +# curl -d '{"method": "web.add_torrents", "params": [[{"path":/Users/despiegk1/Downloads/vlc-3.0.20-arm64.dmg", "options":null}]], "id": 1}' -K curl.cfg \ No newline at end of file diff --git a/deluge/deluge_start.sh b/deluge/deluge_start.sh new file mode 100755 index 0000000..72c1701 --- /dev/null +++ b/deluge/deluge_start.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +deluge -c deluge_conf -s web +deluge -c deluge_conf web +echo "default passwd is 'deluge'" +open http://localhost:8112/ + +# curl -d '{"method": "web.add_torrents", "params": [[{"path":/Users/despiegk1/Downloads/vlc-3.0.20-arm64.dmg", "options":null}]], "id": 1}' -K curl.cfg \ No newline at end of file diff --git a/deluge/existing.torrent b/deluge/existing.torrent new file mode 100644 index 0000000..8ad4c7e Binary files /dev/null and b/deluge/existing.torrent differ diff --git a/deluge/my.torrent b/deluge/my.torrent new file mode 100644 index 0000000..1b97968 --- /dev/null +++ b/deluge/my.torrent @@ -0,0 +1,4 @@ +d7:comment9:Cool Test10:created by18:My Torrent Creator13:creation datei1705127067e4:infod9:file treed7:archived32:state-2024-01-13T09-17-00.tar.xzd0:d6:lengthi268e11:pieces root32:fئtF?Rl2oee11:deluged.logd0:d6:lengthi0eee11:deluged.pidd0:d6:lengthi11e11:pieces root32:x1TI>|=& +) Uee13:hostlist.confd0:d6:lengthi252e11:pieces root32:C(G4YP:b lko-2mee3:ssld11:daemon.certd0:d6:lengthi977e11:pieces root32:YG+Z<0=X7/ee11:daemon.pkeyd0:d6:lengthi1704e11:pieces root32:p6p 1/+cF eee5:stated17:.safe_state_checkd0:d6:lengthi0eee14:torrents.stated0:d6:lengthi80e11:pieces root32:yP03 + +Hkx0&YcӒceee7:ui.confd0:d6:lengthi61e11:pieces root32:M2Ga0=Q\"ee8:web.confd0:d6:lengthi783e11:pieces root32:6Ie6*U`4(>U'eee12:meta versioni2e4:name11:deluge_conf12:piece lengthi16384ee12:piece layersdee \ No newline at end of file diff --git a/deluge/readme.md b/deluge/readme.md new file mode 100644 index 0000000..da654da --- /dev/null +++ b/deluge/readme.md @@ -0,0 +1 @@ +https://deluge.readthedocs.io/en/latest/devguide/how-to/curl-jsonrpc.html diff --git a/deluge/torrent_test.py b/deluge/torrent_test.py new file mode 100755 index 0000000..ef2252c --- /dev/null +++ b/deluge/torrent_test.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +import libtorrent as lt +import time + +def create_torrent(directory, torrent_file_name): + # Create a new file storage object + fs = lt.file_storage() + + # Add files from the directory to the file storage + lt.add_files(fs, directory) + + # Create a new create_torrent object + t = lt.create_torrent(fs, flags=lt.create_torrent_flags_t.v2_only) + + # Add tracker + # t.add_tracker("http://your-tracker.com/announce") + + # Set comment or other properties (optional) + t.set_comment("Cool Test") + t.set_creator("My Torrent Creator") + + # Generate the torrent + lt.set_piece_hashes(t, ".") # Second argument is the root directory for the files + torrent = t.generate() + + # Write the torrent file + with open(torrent_file_name, "wb") as f: + f.write(lt.bencode(torrent)) + + +def read_torrent_v2(file_path): + # Create a torrent_info object from the file path + info = lt.torrent_info(file_path) + + # Accessing various properties of the torrent + print("Torrent Name:", info.name()) + print("Number of Files:", info.num_files()) + print("Total Size:", info.total_size()) + + # Loop through each file in the torrent + for i in range(info.num_files()): + file = info.files().file_path(i) + size = info.files().file_size(i) + print(f"File {i}: {file}, Size: {size}") + +# Example usage +create_torrent("deluge_conf","my.torrent") +read_torrent_v2("existing.torrent") +read_torrent_v2("my.torrent") + + diff --git a/nupower b/nupower new file mode 120000 index 0000000..1ff2e6d --- /dev/null +++ b/nupower @@ -0,0 +1 @@ +/Users/despiegk1/code/git.ourworld.tf/freeflowuniverse/nu/nupower \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..50e2d69 --- /dev/null +++ b/shell.nix @@ -0,0 +1,25 @@ +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11"; + pkgs = import nixpkgs { config = {}; overlays = []; }; +in + +pkgs.mkShell { + packages = with pkgs; [ + git + nushell + mc + jq + # vscode + deluge + libtorrent-rasterbar + python311Packages.libtorrent-rasterbar + python311Full + python311Packages.ipython + python311Packages.ipdb + python311Packages.rq + # dumptorrent + # udpt + # buildtorrent + + ]; +} \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..55d41c1 --- /dev/null +++ b/start.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex +export NIXPKGS_ALLOW_UNFREE=1 +nix-shell \ No newline at end of file