Skip to content

Commit

Permalink
Очередной фикс regex тиктоника
Browse files Browse the repository at this point in the history
  • Loading branch information
Spliterash committed Sep 24, 2024
1 parent a4189f7 commit 9cff762
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TiktokChain(
private val pattern =
Pattern.compile("https?://([a-zA-Z0-9-]+\\.)*tiktok\\.com(/[^\\s]*)?")
private val directUrlPattern =
Pattern.compile("https?://www\\.tiktok\\.com/@[\\w.]+/(?<type>video|photo)/(?<id>\\d+)")
Pattern.compile("https?://www\\.tiktok\\.com/@[\\w.]*/(?<type>video|photo)/(?<id>\\d+)")

override suspend fun handle(message: RootMessage, editableMessage: EditableMessage): Boolean = coroutineScope {
val videoUrlInit = messageScanner.scanForText(message) {
Expand All @@ -38,7 +38,7 @@ class TiktokChain(
videoUrl = redirectHelper.finalUrl(videoUrl)
directUrlMatcher = directUrlPattern.matcher(videoUrl)

if (!directUrlMatcher.find()) throw IllegalStateException("Unable to normalize tiktok url. Init $videoUrl, after try $videoUrlInit")
if (!directUrlMatcher.find()) throw IllegalStateException("Unable to normalize tiktok url. Init $videoUrlInit, after try $videoUrl")
}
editableMessage.sendOrUpdate("Начинаем обработку tiktok контента, это может быть долго")
val contentType = directUrlMatcher.group("type")
Expand Down

0 comments on commit 9cff762

Please sign in to comment.