libtorrent上的简单torrent客户端

sstc的Python项目详细描述


https://img.shields.io/pypi/v/sstc.svg

在libtorrent python绑定之上构建的愚蠢、简单的torrent客户端。

允许您添加Torrent文件和Magnet并接收LibTorrent警报。就这些!

  • 免费软件:wtfpl

功能

  • 待办事项

完整示例

这个例子展示了如何添加磁铁uri以及如何创建警报处理程序。

警报处理程序方法应命名为“on_alert”,其中alert的类型为alert 去处理。

所有方法都将接收会话作为第一个参数和警报 作为第二个。

请注意,这个例子并不详尽。

# coding: utf-8importsysimportosimporttimeimportloggingfromsstc.sstcimportTorrentClientlogging.basicConfig(level=logging.DEBUG)logger=logging.getLogger(__name__)classAlertHandler(object):defon_torrent_added_alert(self,session,alert):logger.debug("on_torrent_added_alert")defon_state_changed_alert(self,session,alert):logger.debug("on_state_changed_alert")logger.debug(alert.message())defon_torrent_resumed_alert(self,session,alert):logger.debug("on_torrent_resumed_alert")defon_torrent_checked_alert(self,session,alert):logger.debug("on_torrent_checked_alert")handler=alert.handleinfo=handler.get_torrent_info()files=info.files()# Do something with torrent infos, like filter files to download# torrent was added paused, we resume ithandler.resume()defon_torrent_finished_alert(self,session,alert):logger.debug("on_torrent_finished_alert")# if you want to remove the torrent immediately :#session.remove_torrent(handler)defon_piece_finished_alert(self,session,alert):logger.debug("on_torrent_finished_alert")handler=alert.handledefon_block_finished_alert(self,session,alert):logger.debug("on_block_finished_alert")handler=alert.handledefon_file_completed_alert(self,session,alert):logger.debug("on_file_completed_alert")handler=alert.handleinfo=handler.get_torrent_info()f=info.file_at(alert.index)logger.debug("%s : completed",f.path)defmain():# starts client with 100Mib/s download limit# and 10Mib/s uploadlimitclient=TorrentClient(download_rate_limit=100<<20,upload_rate_limit=10<<20,)# start client alert dispatcherclient.start()to_download=[# support local torrentfile"./big_buck_bunny.torrent"# also magnet url"magnet:?xt=urn:btih:0E876CE2A1A504F849CA72A5E2BC07347B3BC957&dn=big+buck+bunny+720p+psiclone&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce",# also from http/https url"http://www.frostclick.com/torrents/video/animation/Big_Buck_Bunny_1080p_surround_frostclick.com_frostwire.com.torrent",]try:foriteminto_download:client.add(item,is_paused=True,alert_handler=AlertHandler())# Blocking loopclient.loop()except(KeyboardInterrupt,Exception)ase:client.stop()if__name__=="__main__":main()

历史记录

0.1.0(2015-01-11)

  • pypi上的第一个版本。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在饼图的图例中只包含每个类别的长描述?   json Grails应用程序,可以从Java DAO服务访问数据库如何访问控制器中的服务?   java将大型远程数据库表同步到本地数据库表,该表包含字段“lastModificationTime”   java如何在JFrame中创建交互式地图   web服务如何创建异步Java Restlet web服务?   java开始读取特定字节   java在jTable中返回不带SQL的搜索结果(带DAOMock)   jakarta ee java ee MVC模式,模型和视图是否直接相互通信   当由负载平衡器处理时,java Spring引导CSRF失败   java为什么JavaMail连接超时太长   java IzPack需要从安装程序安装JDK/JRE版本   java如何创建一个只接受实现Iterable的元素的方法   java spring数据存储库无法使用idClass保存实体   java如何从列表中删除重复项?   java在SocketChannel中发送大量数据时,影响速度的因素有哪些?   算法分支和绑定错误:节点1无法转换为java。可比的   java使用邮件API从Swing应用程序创建Jar文件   java枚举与简单常量声明?