Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support added for Disney+ #84

Merged
merged 1 commit into from
Nov 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class NetflixReaderService : AccessibilityService() {
readersMap[Constants.PACKAGE_JIO_TV] = JioTvReader()
readersMap[Constants.PACKAGE_YOUTUBE] = YoutubeReader()
readersMap[Constants.PACKAGE_REDBOX] = RedboxReader()
readersMap[Constants.PACKAGE_DISNEY] = DisneyReader()
readersMap[BuildConfig.APPLICATION_ID] = FlutterTestReader()

preferences = SettingsPreferences(this)
Expand Down Expand Up @@ -199,8 +200,8 @@ class NetflixReaderService : AccessibilityService() {

val reader = readersMap[info.packageName]
if (reader != null) {
val titles = reader.readTitles(event, info).distinctBy { it }
val years = reader.readYear(info).distinctBy { it }
val titles = reader.readTitles(event, info).distinctBy { it }.asReversed()
val years = reader.readYear(info).distinctBy { it }.asReversed()
if (BuildConfig.DEBUG) {
if (titles.isEmpty()) {
checkNodeRecursively(info, 0)
Expand All @@ -218,7 +219,6 @@ class NetflixReaderService : AccessibilityService() {
event.packageName.toString()
)
}

} else {
checkNodeRecursively(info, 0)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.fenchtose.movieratings.reader

import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo
import com.fenchtose.movieratings.util.Constants
import com.fenchtose.movieratings.util.FixTitleUtils

class DisneyReader : AppReader {
override fun readTitles(
event: AccessibilityEvent,
info: AccessibilityNodeInfo
): List<CharSequence> {
return findText(info, "title")
}

override fun readYear(info: AccessibilityNodeInfo): List<CharSequence> {
return findText(info, "metaData")
}

override fun fixYear(text: String): String {
return FixTitleUtils.fixDisneyYear(text) ?: ""
}

override fun getAppId() = Constants.PACKAGE_DISNEY

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Constants {
const val PACKAGE_JIO_TV = "com.jio.jioplay.tv"
const val PACKAGE_JIO_CINEMA = "com.jio.media.ondemand"
const val PACKAGE_REDBOX = "com.redbox.android.activity"
const val PACKAGE_DISNEY = "com.disney.disneyplus"

const val APP_SHARE_URL = "http://bit.ly/movieRatings"

Expand All @@ -35,7 +36,8 @@ class Constants {
Pair(PACKAGE_HOTSTAR, R.string.settings_hotstar),
Pair(PACKAGE_JIO_TV, R.string.settings_jio_tv),
Pair(PACKAGE_JIO_CINEMA, R.string.settings_jio_cinema),
Pair(PACKAGE_REDBOX, R.string.settings_redbox)
Pair(PACKAGE_REDBOX, R.string.settings_redbox),
Pair(PACKAGE_DISNEY, R.string.settings_disney)
)

const val SUPPORT_CHANNEL_ID = "support"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class FixTitleUtils {

val PRIMEVIDEO_PATTERN = "[^a-zA-Z0-9 ]".toRegex()
val NETFLIX_YEAR_PATTERN = "[1-9]\\d{3}".toRegex()
val DISNEY_YEAR_PATTERN = " [1-9]\\d{3} ".toRegex() // Space in front
val PLAY_MOVIES_YEAR_TIME_PATTERN = "[1-9]\\d{3},\\s\\d+\\s\\w+".toRegex()

fun fixPrimeVideoTitle(title: String): String {
Expand Down Expand Up @@ -36,6 +37,10 @@ class FixTitleUtils {
return PLAY_MOVIES_YEAR_TIME_PATTERN.matches(year)
}

fun fixDisneyYear(year: String): String? {
return DISNEY_YEAR_PATTERN.find(year)?.value
}

fun splitYears(year: String): List<String> {
val results = NETFLIX_YEAR_PATTERN.findAll(year)
return results.map { it.value }.toList()
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<string name="settings_jio_tv">Jio TV</string>
<string name="settings_jio_cinema">Jio Cinema</string>
<string name="settings_redbox">Redbox</string>
<string name="settings_disney">Disney+</string>
<string name="settings_preference_update_content">Your preferences have been updated</string>
<string name="settings_not_installed_apps">Flutter also supports %1s - which are not installed on your device.</string>
<string name="settings_toast_duration_info">Set the duration for movie ratings to be displayed on your screen (in seconds)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/serviceconfig.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeWindowStateChanged|typeWindowContentChanged"
android:packageNames="com.netflix.mediaclient, com.amazon.avod.thirdpartyclient, com.google.android.videos, in.startv.hotstar, com.google.android.youtube, bbc.iplayer.android, com.jio.jioplay.tv, com.jio.media.ondemand, com.redbox.android.activity, android.system.ui"
android:packageNames="com.netflix.mediaclient, com.amazon.avod.thirdpartyclient, com.google.android.videos, in.startv.hotstar, com.google.android.youtube, bbc.iplayer.android, com.jio.jioplay.tv, com.jio.media.ondemand, com.redbox.android.activity, com.disney.disneyplus, android.system.ui"
android:description="@string/accessibility_description"
android:summary="@string/accessibility_summary"
android:accessibilityFeedbackType="feedbackGeneric"
Expand Down