1- use crate :: data :: increment_requests ;
1+ use std :: sync :: Arc ;
22use reqwest:: { header, Client } ;
33use serde_json:: Value ;
4+ use crate :: database:: Database ;
5+ use crate :: logger:: LOGGER ;
46
57// https://github.com/ShaheenJawadi/tiktok-video-downloader
6- pub async fn parse_tiktok_content ( url : & str , id : u64 ) -> Result < Box < dyn Media > , String > {
8+ pub async fn parse_tiktok_content ( url : & str , id : i64 , db : & Database ) -> Result < Box < dyn Media > , String > {
79 let client = Client :: new ( ) ;
8- println ! ( "🔍 Fetching video metadata...") ;
10+ LOGGER . info ( " Fetching video metadata...") ;
911
1012 let api_url = format ! ( "https://www.tikwm.com/api/?url={}" , url) ;
1113 let response = client. get ( & api_url)
@@ -36,11 +38,11 @@ pub async fn parse_tiktok_content(url: &str, id: u64) -> Result<Box<dyn Media>,
3638 . unwrap_or ( "https://moosic.my.mail.ru/file/7aa9b68114dfa1a4581ce525a1e793b1.mp3" ) ;
3739
3840 // adding +1 to requests_amount on users.json
39- increment_requests ( id) . await . unwrap ( ) ;
41+ db . increment_requests ( id) . await . unwrap ( ) ;
4042
4143 if !images_url. is_empty ( ) {
4244
43- println ! ( "🔍 Fetching has been finished!") ;
45+ LOGGER . success ( " Fetching has been finished!") ;
4446 return Ok ( Box :: new (
4547 PhotoContent {
4648 title : video_title. to_string ( ) ,
@@ -54,7 +56,7 @@ pub async fn parse_tiktok_content(url: &str, id: u64) -> Result<Box<dyn Media>,
5456 . as_str ( )
5557 . ok_or ( "Video URL not found in API response" . to_string ( ) ) ?;
5658
57- println ! ( "🔍 Fetching has been finished!") ;
59+ LOGGER . success ( " Fetching has been finished!") ;
5860
5961 Ok (
6062 Box :: from ( VideoContent {
0 commit comments