Skip to content

Commit

Permalink
Use Chrome/Android user agent for beatmap downloader requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed May 5, 2024
1 parent 41e0134 commit 96309a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
10 changes: 7 additions & 3 deletions src/com/reco1l/osu/beatmaplisting/BeatmapDownloader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.reco1l.osu.beatmaplisting

import android.os.Environment.DIRECTORY_DOWNLOADS
import android.view.View
import com.reco1l.osu.mainThread
import com.reco1l.framework.net.FileRequest
import com.reco1l.framework.net.IDownloaderObserver
import com.reco1l.osu.mainThread
import com.reco1l.osu.multiplayer.Multiplayer
import com.reco1l.osu.ui.DownloadFragment
import com.reco1l.osu.multiplayer.RoomScene
import com.reco1l.osu.ui.DownloadFragment
import com.reco1l.toolkt.kotlin.async
import com.reco1l.toolkt.kotlin.decodeAsURL
import com.reco1l.toolkt.kotlin.replaceAlphanumeric
Expand All @@ -21,7 +21,6 @@ import ru.nsu.ccfit.zuev.osu.helper.FileUtils
import ru.nsu.ccfit.zuev.osu.helper.StringTable
import ru.nsu.ccfit.zuev.osuplus.R
import java.io.IOException
import java.lang.Exception

object BeatmapDownloader : IDownloaderObserver {

Expand Down Expand Up @@ -57,6 +56,11 @@ object BeatmapDownloader : IDownloaderObserver {
val file = directory?.resolve("$filename.osz")!!

val downloader = FileRequest(file, url)
downloader.buildRequest {

removeHeader("User-Agent")
addHeader("User-Agent", "Chrome/Android")
}

fragment = DownloadFragment()
fragment.setDownloader(downloader) {
Expand Down
32 changes: 11 additions & 21 deletions src/com/reco1l/osu/beatmaplisting/BeatmapListing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@ package com.reco1l.osu.beatmaplisting

import android.graphics.BitmapFactory
import android.util.Log
import android.view.ContextThemeWrapper
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
import android.view.View.OnKeyListener
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.view.ViewOutlineProvider
import android.view.*
import android.view.View.*
import android.view.inputmethod.EditorInfo
import android.widget.Button
import android.widget.EditText
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.*
import android.widget.TextView.OnEditorActionListener
import androidx.core.text.buildSpannedString
import androidx.core.text.color
Expand All @@ -33,11 +21,7 @@ import com.reco1l.framework.net.IDownloaderObserver
import com.reco1l.framework.net.JsonArrayRequest
import com.reco1l.osu.OsuColors
import com.reco1l.osu.mainThread
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.*
import ru.nsu.ccfit.zuev.audio.Status
import ru.nsu.ccfit.zuev.osu.Config
import ru.nsu.ccfit.zuev.osu.GlobalManager
Expand All @@ -46,7 +30,7 @@ import ru.nsu.ccfit.zuev.osu.ToastLogger
import ru.nsu.ccfit.zuev.osuplus.R
import java.net.URL
import java.text.SimpleDateFormat
import java.util.TimeZone
import java.util.*


object BeatmapListing : BaseFragment(),
Expand Down Expand Up @@ -160,6 +144,12 @@ object BeatmapListing : BaseFragment(),
addQueryParameter("offset", offset.toString())
}

request.buildRequest {

removeHeader("User-Agent")
addHeader("User-Agent", "Chrome/Android")
}

val beatmapSets = mirror.search.mapResponse(request.execute().json)
adapter.data.addAll(beatmapSets)

Expand Down

0 comments on commit 96309a6

Please sign in to comment.