UPNP: add size attribute
This commit is contained in:
parent
bf910d39f2
commit
ff7924ff78
4 changed files with 14 additions and 5 deletions
|
|
@ -62,7 +62,8 @@ impl TorrentFileTreeNode {
|
||||||
let encoded_parent_id = self.parent_id.map(|p| encode_id(p, torrent.id()));
|
let encoded_parent_id = self.parent_id.map(|p| encode_id(p, torrent.id()));
|
||||||
match self.real_torrent_file_id {
|
match self.real_torrent_file_id {
|
||||||
Some(fid) => {
|
Some(fid) => {
|
||||||
let filename = &torrent.shared().file_infos[fid].relative_filename;
|
let fi = &torrent.shared().file_infos[fid];
|
||||||
|
let filename = &fi.relative_filename;
|
||||||
// Torrent path joined with "/"
|
// Torrent path joined with "/"
|
||||||
let last_url_bit = torrent
|
let last_url_bit = torrent
|
||||||
.shared()
|
.shared()
|
||||||
|
|
@ -91,6 +92,7 @@ impl TorrentFileTreeNode {
|
||||||
fid,
|
fid,
|
||||||
last_url_bit
|
last_url_bit
|
||||||
),
|
),
|
||||||
|
size: fi.len,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
None => ItemOrContainer::Container(Container {
|
None => ItemOrContainer::Container(Container {
|
||||||
|
|
@ -588,7 +590,8 @@ mod tests {
|
||||||
parent_id: 0,
|
parent_id: 0,
|
||||||
title: "f1".into(),
|
title: "f1".into(),
|
||||||
mime_type: None,
|
mime_type: None,
|
||||||
url: "http://127.0.0.1:9005/torrents/0/stream/0/f1".into()
|
url: "http://127.0.0.1:9005/torrents/0/stream/0/f1".into(),
|
||||||
|
size: 1,
|
||||||
}),
|
}),
|
||||||
ItemOrContainer::Container(Container {
|
ItemOrContainer::Container(Container {
|
||||||
id: encode_id(0, 1),
|
id: encode_id(0, 1),
|
||||||
|
|
@ -606,7 +609,8 @@ mod tests {
|
||||||
parent_id: 0,
|
parent_id: 0,
|
||||||
title: "f1".into(),
|
title: "f1".into(),
|
||||||
mime_type: None,
|
mime_type: None,
|
||||||
url: "http://127.0.0.1:9005/torrents/0/stream/0/f1".into()
|
url: "http://127.0.0.1:9005/torrents/0/stream/0/f1".into(),
|
||||||
|
size: 1,
|
||||||
})]
|
})]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -648,6 +652,7 @@ mod tests {
|
||||||
title: "f2".into(),
|
title: "f2".into(),
|
||||||
mime_type: None,
|
mime_type: None,
|
||||||
url: "http://127.0.0.1:9005/torrents/1/stream/0/d1/f2".into(),
|
url: "http://127.0.0.1:9005/torrents/1/stream/0/d1/f2".into(),
|
||||||
|
size: 1,
|
||||||
})]
|
})]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -659,6 +664,7 @@ mod tests {
|
||||||
title: "f2".into(),
|
title: "f2".into(),
|
||||||
mime_type: None,
|
mime_type: None,
|
||||||
url: "http://127.0.0.1:9005/torrents/1/stream/0/d1/f2".into(),
|
url: "http://127.0.0.1:9005/torrents/1/stream/0/d1/f2".into(),
|
||||||
|
size: 1,
|
||||||
})]
|
})]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
url: "http://192.168.0.165:3030/torrents/4/stream/0/file.mkv".to_owned(),
|
url: "http://192.168.0.165:3030/torrents/4/stream/0/file.mkv".to_owned(),
|
||||||
id: 1,
|
id: 1,
|
||||||
parent_id: 0,
|
parent_id: 0,
|
||||||
|
size: 1,
|
||||||
})];
|
})];
|
||||||
|
|
||||||
const HTTP_PORT: u16 = 9005;
|
const HTTP_PORT: u16 = 9005;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<item id="{id}" parentID="{parent_id}" restricted="true">
|
<item id="{id}" parentID="{parent_id}" restricted="true">
|
||||||
<dc:title>{title}</dc:title>
|
<dc:title>{title}</dc:title>
|
||||||
<upnp:class>{upnp_class}</upnp:class>
|
<upnp:class>{upnp_class}</upnp:class>
|
||||||
<res protocolInfo="http-get:*:{mime_type}:DLNA.ORG_OP=01">{url}</res>
|
<res protocolInfo="http-get:*:{mime_type}:DLNA.ORG_OP=01" size="{size}">{url}</res>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ pub mod browse {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub mime_type: Option<mime_guess::Mime>,
|
pub mime_type: Option<mime_guess::Mime>,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
pub size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
|
@ -103,7 +104,8 @@ pub mod browse {
|
||||||
mime_type = mime,
|
mime_type = mime,
|
||||||
url = item.url,
|
url = item.url,
|
||||||
upnp_class = upnp_class,
|
upnp_class = upnp_class,
|
||||||
title = item.title
|
title = item.title,
|
||||||
|
size = item.size
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue