Exemplo n.º 1
0
def test_compose_magnetlink():
    infohash = "DC4B96CF85A85CEEDB8ADC4B96CF85A85CEEDB8A"
    name = "Some torrent name"
    trackers = [
        'http://tracker1.example.com:8080/announce',
        'http://tracker1.example.com:8080/announce'
    ]

    expected_link0 = ""
    expected_link1 = "magnet:?xt=urn:btih:DC4B96CF85A85CEEDB8ADC4B96CF85A85CEEDB8A"
    expected_link2 = "magnet:?xt=urn:btih:DC4B96CF85A85CEEDB8ADC4B96CF85A85CEEDB8A&dn=Some+torrent+name"
    expected_link3 = (
        "magnet:?xt=urn:btih:DC4B96CF85A85CEEDB8ADC4B96CF85A85CEEDB8A&dn=Some+torrent+name"
        "&tr=http://tracker1.example.com:8080/announce&tr=http://tracker1.example.com:8080/announce"
    )

    composed_link0 = compose_magnetlink(None)
    composed_link1 = compose_magnetlink(infohash)
    composed_link2 = compose_magnetlink(infohash, name=name)
    composed_link3 = compose_magnetlink(infohash, name=name, trackers=trackers)

    assert composed_link0 == expected_link0
    assert composed_link1 == expected_link1
    assert composed_link2 == expected_link2
    assert composed_link3 == expected_link3
Exemplo n.º 2
0
 def on_copy_magnet_clicked(self):
     magnet_link = compose_magnetlink(
         self.torrent_info['infohash'],
         name=self.torrent_info.get('name', None),
         trackers=self.torrent_info.get('trackers', None),
     )
     copy_to_clipboard(magnet_link)
     self.window().tray_show_message("Copying magnet link", magnet_link)
Exemplo n.º 3
0
 def on_copy_magnet_clicked(self, checked):
     trackers = [
         tk['url'] for tk in self.current_download['trackers'] if 'url' in tk and tk['url'] not in ['[DHT]', '[PeX]']
     ]
     magnet_link = compose_magnetlink(
         self.current_download['infohash'], name=self.current_download.get('name', None), trackers=trackers
     )
     copy_to_clipboard(magnet_link)
     self.window().tray_show_message(tr("Copying magnet link"), magnet_link)
Exemplo n.º 4
0
 def on_add_button_pressed(channel_id):
     for selected_item in self.selected_items:
         infohash = selected_item.download_info["infohash"]
         name = selected_item.download_info["name"]
         TriblerNetworkRequest(
             f"channels/mychannel/{channel_id}/torrents",
             lambda _: self.window().tray_show_message("Channel update", "Torrent(s) added to your channel"),
             method='PUT',
             data={"uri": compose_magnetlink(infohash, name=name)},
         )