@@ -30,7 +30,6 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
30
30
fs:: { metadata, read_dir, File } ,
31
31
io:: { Read , Write } ,
32
32
} ;
33
- use url:: Url ;
34
33
35
34
output. debug ( "feed update begin" ) ;
36
35
@@ -51,16 +50,23 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
51
50
52
51
let mut data = Vec :: new ( ) ;
53
52
54
- let destination = match item. pub_date ( ) {
53
+ let ( destination, pub_date ) = match item. pub_date ( ) {
55
54
Some ( pub_date) => {
56
55
let destination = Destination :: build ( & argument. target , pub_date, true ) ?;
57
56
if metadata ( destination. item ( ) ) . is_ok ( ) {
58
57
exist += 1 ;
59
58
continue ;
60
59
}
61
60
62
- data. push ( format ! ( "# {pub_date}" ) ) ;
63
- destination
61
+ data. push ( format ! (
62
+ "# {}" ,
63
+ match item. title( ) {
64
+ Some ( title) => title,
65
+ None => pub_date,
66
+ }
67
+ ) ) ;
68
+
69
+ ( destination, pub_date)
64
70
}
65
71
None => {
66
72
output. warning ( "item skipped as `pub_date` required by application" ) ;
@@ -77,19 +83,7 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
77
83
}
78
84
79
85
if let Some ( link) = item. link ( ) {
80
- data. push ( match Url :: parse ( link) {
81
- Ok ( url) => {
82
- if let Some ( host) = url. host_str ( ) {
83
- format ! ( "=> {link} {host}" )
84
- } else {
85
- format ! ( "=> {link}" )
86
- }
87
- }
88
- Err ( e) => {
89
- output. warning ( & e. to_string ( ) ) ;
90
- format ! ( "=> {link}" )
91
- }
92
- } )
86
+ data. push ( format ! ( "=> {link} {pub_date}" ) )
93
87
}
94
88
95
89
File :: create ( destination. item ( ) ) ?. write_all ( data. join ( "\n \n " ) . as_bytes ( ) ) ?;
0 commit comments