Skip to content

Instantly share code, notes, and snippets.

@Derkades
Created February 16, 2024 13:52
Show Gist options
  • Save Derkades/4327ba82eb559274ab47dec2662b66fc to your computer and use it in GitHub Desktop.
Save Derkades/4327ba82eb559274ab47dec2662b66fc to your computer and use it in GitHub Desktop.
Import torrents from magnetico into bitmagnet DHT crawler

See bitmagnet's import endpoint documentation for more information.

sqlite3 -json -batch database.sqlite3 "$(cat magnetico-import.sql)" | 
  jq -r --indent 0 '.[]' | 
  curl --verbose -H "Content-Type: application/json" -H "Connection: close" --data-binary @- http://localhost:3333/import
SELECT
"magnetico" AS source,
hex(info_hash) AS infoHash,
name,
total_size AS size,
strftime('%Y-%m-%dT%H:%M:%fZ', DATETIME(discovered_on, 'unixepoch')) AS publishedAt
FROM torrents
ORDER BY info_hash
-- you may want to enable the following line while testing your query
--limit 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment