@@ -73,46 +73,20 @@ fun getVersionName(): String {
73
73
}
74
74
}
75
75
76
- tasks.register(" modifySource" ) {
77
- doFirst {
78
- val net = project.findProperty(" net" ) ? : " "
79
- println (" net: $net " )
80
-
81
- val channels = when (net) {
82
- " ipv6" -> " R.raw.ipv6"
83
- " mobile" -> " R.raw.itv"
84
- else -> " "
85
- }
86
-
87
- if (channels.isNotEmpty()) {
88
- val f = file(" src/main/java/com/lizongying/mytv0/models/TVList.kt" )
89
- f.writeText(f.readText().replace(" R.raw.channels" , channels))
90
- }
91
-
92
- val url = when (net) {
93
- " ipv6" -> " DEFAULT_CONFIG_URL = \" https://live.fanmingming.com/tv/m3u/ipv6.m3u\" "
94
- " mobile" -> " DEFAULT_CONFIG_URL = \" https://live.fanmingming.com/tv/m3u/itv.m3u\" "
95
- else -> " "
96
- }
97
-
98
- if (url.isNotEmpty()) {
99
- val f = file(" src/main/java/com/lizongying/mytv0/SP.kt" )
100
- f.writeText(f.readText().replace(" DEFAULT_CONFIG_URL = \"\" " , url))
101
- }
102
- }
76
+ task(" modifySource" ) {
103
77
doLast {
104
78
val net = project.findProperty(" net" ) ? : " "
105
79
println (" net: $net " )
106
80
107
81
val channels = when (net) {
108
- " ipv6" -> " R.raw. ipv6"
109
- " mobile" -> " R.raw.itv "
110
- else -> " "
82
+ " ipv6" -> " assets/ ipv6.txt "
83
+ " mobile" -> " assets/mobile.txt "
84
+ else -> " assets/common.txt "
111
85
}
112
86
113
87
if (channels.isNotEmpty()) {
114
- val f = file(" src/main/java/com/lizongying/mytv0/models/TVList.kt " )
115
- f.writeText(f.readText().replace(channels, " R.raw.channels " ))
88
+ val f = file(" src/main/res/raw/channels.txt " )
89
+ f.writeText(file(channels).readText( ))
116
90
}
117
91
118
92
val url = when (net) {
@@ -123,65 +97,27 @@ tasks.register("modifySource") {
123
97
124
98
if (url.isNotEmpty()) {
125
99
val f = file(" src/main/java/com/lizongying/mytv0/SP.kt" )
126
- f.writeText(f.readText().replace(url, " DEFAULT_CONFIG_URL = \"\" " ))
100
+ f.writeText(f.readText().replace(" DEFAULT_CONFIG_URL = \"\" " , url ))
127
101
}
128
102
}
129
103
}
130
104
131
105
tasks.whenTaskAdded {
132
106
if (name == " assembleRelease" ) {
133
- tasks.named(" assembleRelease" ) {
134
- doFirst {
135
- val net = project.findProperty(" net" ) ? : " "
136
- println (" net: $net " )
137
-
138
- val channels = when (net) {
139
- " ipv6" -> " R.raw.ipv6"
140
- " mobile" -> " R.raw.itv"
141
- else -> " "
142
- }
143
-
144
- if (channels.isNotEmpty()) {
145
- val f = file(" src/main/java/com/lizongying/mytv0/models/TVList.kt" )
146
- f.writeText(f.readText().replace(" R.raw.channels" , channels))
147
- }
148
-
149
- val url = when (net) {
150
- " ipv6" -> " DEFAULT_CONFIG_URL = \" https://live.fanmingming.com/tv/m3u/ipv6.m3u\" "
151
- " mobile" -> " DEFAULT_CONFIG_URL = \" https://live.fanmingming.com/tv/m3u/itv.m3u\" "
152
- else -> " "
153
- }
154
-
155
- if (url.isNotEmpty()) {
156
- val f = file(" src/main/java/com/lizongying/mytv0/SP.kt" )
157
- f.writeText(f.readText().replace(" DEFAULT_CONFIG_URL = \"\" " , url))
158
- }
107
+ dependsOn(" modifySource" )
108
+ doLast {
109
+ val net = project.findProperty(" net" ) ? : " "
110
+ println (" net: $net " )
111
+
112
+ val url = when (net) {
113
+ " ipv6" -> " DEFAULT_CONFIG_URL = \" https://live.fanmingming.com/tv/m3u/ipv6.m3u\" "
114
+ " mobile" -> " DEFAULT_CONFIG_URL = \" https://live.fanmingming.com/tv/m3u/itv.m3u\" "
115
+ else -> " "
159
116
}
160
- doLast {
161
- val net = project.findProperty(" net" ) ? : " "
162
- println (" net: $net " )
163
-
164
- val channels = when (net) {
165
- " ipv6" -> " R.raw.ipv6"
166
- " mobile" -> " R.raw.itv"
167
- else -> " "
168
- }
169
-
170
- if (channels.isNotEmpty()) {
171
- val f = file(" src/main/java/com/lizongying/mytv0/models/TVList.kt" )
172
- f.writeText(f.readText().replace(channels, " R.raw.channels" ))
173
- }
174
-
175
- val url = when (net) {
176
- " ipv6" -> " DEFAULT_CONFIG_URL = \" https://live.fanmingming.com/tv/m3u/ipv6.m3u\" "
177
- " mobile" -> " DEFAULT_CONFIG_URL = \" https://live.fanmingming.com/tv/m3u/itv.m3u\" "
178
- else -> " "
179
- }
180
-
181
- if (url.isNotEmpty()) {
182
- val f = file(" src/main/java/com/lizongying/mytv0/SP.kt" )
183
- f.writeText(f.readText().replace(url, " DEFAULT_CONFIG_URL = \"\" " ))
184
- }
117
+
118
+ if (url.isNotEmpty()) {
119
+ val f = file(" src/main/java/com/lizongying/mytv0/SP.kt" )
120
+ f.writeText(f.readText().replace(url, " DEFAULT_CONFIG_URL = \"\" " ))
185
121
}
186
122
}
187
123
}
0 commit comments