if($number_of_page != $i){
$telegram->deleteMessage([
"chat_id" => $callback_chat_id,
"message_id" => $callback_message_id,
]);
}
? if($number_of_page <= $i){
1 <= 0 Не проходим
} elseif ($number_of_page >= ($catalog_count-1)){
Суда тоже мы не проходим, Ну не может же быть число $catalog_count-1 меньше либо равно нулю.
}
if($number_of_page != $i){
1 != 0 Не проходим
}
guard let videoURL = URL(string: i) else { return }
guard let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
if FileManager.default.fileExists(atPath: documentsDirectoryURL.appendingPathComponent(videoURL.lastPathComponent).path) {
do {
FileManager.default.removeItem(atPath: documentsDirectoryURL.appendingPathComponent(videoURL.lastPathComponent).path)
} catch { print(error) }
}
// set up your download task
URLSession.shared.downloadTask(with: videoURL) { (location, response, error) -> Void in
// use guard to unwrap your optional url
guard let location = location else { return }
// create a deatination url with the server response suggested file name
let destinationURL = documentsDirectoryURL.appendingPathComponent(response?.suggestedFilename ?? videoURL.lastPathComponent)
do {
try FileManager.default.moveItem(at: location, to: destinationURL)
PHPhotoLibrary.requestAuthorization({ (authorizationStatus: PHAuthorizationStatus) -> Void in
// check if user authorized access photos for your app
if authorizationStatus == .authorized {
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: destinationURL) }) { completed, error in
if completed {
print("Video asset created")
} else {
print(error)
}
}
}
})
} catch { print(error) }
}.resume()