recycleactor commited on
Commit
42d01dc
·
verified ·
1 Parent(s): ce63977

Upload soundcloud.rs

Browse files
Files changed (1) hide show
  1. src/soundcloud.rs +22 -11
src/soundcloud.rs CHANGED
@@ -89,24 +89,35 @@ pub async fn search(Query(params): Query<SearchParams>) -> impl IntoResponse {
89
  let mut tracks = Vec::new();
90
 
91
  for (idx, line) in stdout.lines().enumerate() {
 
92
  let parts: Vec<&str> = line.split("|||").collect();
 
 
93
  if parts.len() >= 5 {
94
  // ID может быть числом или строкой, используем строку как permalink
95
  let id_str = parts[0];
96
  let id_num = id_str.parse::<u64>().unwrap_or(idx as u64);
97
 
98
- if let Ok(duration) = parts[3].parse::<u64>() {
99
- tracks.push(Track {
100
- id: id_num,
101
- title: parts[1].to_string(),
102
- permalink: id_str.to_string(),
103
- permalink_url: parts[4].to_string(),
104
- duration: duration * 1000, // в миллисекундах для совместимости
105
- user: User {
106
- username: parts[2].to_string(),
107
- },
108
- });
 
 
 
 
 
 
109
  }
 
 
110
  }
111
  }
112
 
 
89
  let mut tracks = Vec::new();
90
 
91
  for (idx, line) in stdout.lines().enumerate() {
92
+ tracing::info!("Line {}: {}", idx, line);
93
  let parts: Vec<&str> = line.split("|||").collect();
94
+ tracing::info!("Parts count: {}", parts.len());
95
+
96
  if parts.len() >= 5 {
97
  // ID может быть числом или строкой, используем строку как permalink
98
  let id_str = parts[0];
99
  let id_num = id_str.parse::<u64>().unwrap_or(idx as u64);
100
 
101
+ match parts[3].parse::<u64>() {
102
+ Ok(duration) => {
103
+ tracing::info!("Parsed track: id={} title={} duration={}", id_str, parts[1], duration);
104
+ tracks.push(Track {
105
+ id: id_num,
106
+ title: parts[1].to_string(),
107
+ permalink: id_str.to_string(),
108
+ permalink_url: parts[4].to_string(),
109
+ duration: duration * 1000, // в миллисекундах для совместимости
110
+ user: User {
111
+ username: parts[2].to_string(),
112
+ },
113
+ });
114
+ }
115
+ Err(e) => {
116
+ tracing::warn!("Failed to parse duration '{}': {}", parts[3], e);
117
+ }
118
  }
119
+ } else {
120
+ tracing::warn!("Line {} has only {} parts, expected at least 5", idx, parts.len());
121
  }
122
  }
123