Skip to content

Commit

Permalink
Created a python script to convert mp4 files into torrents
Browse files Browse the repository at this point in the history
Also uploaded 20 torrents.
  • Loading branch information
ChelseaGuan committed Mar 8, 2023
1 parent 2567b61 commit bd8f42d
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions detoks/src/main/python/video_to_torrent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pathlib

from torrentool.api import Torrent


def create_torrent_from_video(videos_directory: str, torrents_directory: str, tracker_urls: str = None):
"""
Convert mp4 video files into torrent files and print the magnet link for each.
:param videos_directory: The directory from which to extract the videos.
:param torrents_directory: The directory in which the torrents will be created.
:param tracker_urls: Optional if the user wishes to specify tracker urls.
"""
for video in pathlib.Path(videos_directory).glob('*.mp4'):
torrent = Torrent.create_from(video)
if tracker_urls is not None:
torrent.announce_urls = tracker_urls
pathlib.Path(torrents_directory).mkdir(parents=True, exist_ok=True)
torrent.to_file(f"{torrents_directory}/{video.stem}.torrent")
print(f"{torrent}\n{torrent.magnet_link}\n")


if __name__ == "__main__":
videos_dir = "CC Videos"
torrents_dir = "Torrents"
tracker = "udp://tracker.openbittorrent.com:80"

create_torrent_from_video(videos_dir, torrents_dir, tracker)
Binary file added detoks/src/main/res/raw/Big Buck Bunny.torrent
Binary file not shown.
Binary file added detoks/src/main/res/raw/Cosmos Laundromat.torrent
Binary file not shown.
Binary file not shown.
Binary file added detoks/src/main/res/raw/arcane.torrent
Binary file not shown.
1 change: 1 addition & 0 deletions detoks/src/main/res/raw/cat.torrent
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d8:announce35:udp://tracker.openbittorrent.com:8010:created by16:torrentool/1.1.113:creation datei1678292664e4:infod6:lengthi4050874e4:name7:cat.mp412:piece lengthi262144e6:pieces320:��A����R��p��fN%��,�l_ ��:��۩�����NQ���3�-��gJ����ے.+��:ՠ��K���h|Vp��`�1Q��\iNN�9���h��P�Ԥ�a�K�5;I�_P����<,��6��푯�.Ϧ�Ip��(d����Qi��9������^QKB�P�!�.��YM��0?����&P�ҝ����v���b�����r�8�~����^������s�wly˪��?�)!�`:g+<C�_����A~j.��X�ֱ�y1h��#�/6�^�u���D��'�WU��u��ee
Expand Down
Binary file added detoks/src/main/res/raw/dog.torrent
Binary file not shown.
Binary file added detoks/src/main/res/raw/orange.torrent
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added detoks/src/main/res/raw/sintel.torrent
Binary file not shown.
Binary file added detoks/src/main/res/raw/superthings.torrent
Binary file not shown.

0 comments on commit bd8f42d

Please sign in to comment.