@@ -18,6 +18,7 @@ internal class NyaaAdapter : AdapterBase
18
18
private readonly string pingUrl = "upload" ;
19
19
private readonly string postUrl = "upload" ;
20
20
private string category ;
21
+ private NyaaTorrentFlags torrentFlags ;
21
22
private const string site = "nyaa" ;
22
23
public NyaaAdapter ( TorrentContent torrent , Template template )
23
24
{
@@ -41,6 +42,7 @@ public NyaaAdapter(TorrentContent torrent, Template template)
41
42
httpClientHandler . UseProxy = true ;
42
43
}
43
44
category = CategoryHelper . SelectCategory ( torrent . Tags , site ) ;
45
+ torrentFlags = SetFlags ( torrent . TorrentFlags , torrent . Tags ) ;
44
46
if ( ! Valid ( ) )
45
47
{
46
48
IOHelper . ReadLine ( ) ;
@@ -84,6 +86,28 @@ public override async Task<HttpResult> PostAsync()
84
86
{ new StringContent ( torrent . About ?? "" ) , "information" } ,
85
87
{ new StringContent ( template . Content ?? "" ) , "description" } ,
86
88
} ;
89
+
90
+ if ( torrentFlags != NyaaTorrentFlags . None )
91
+ {
92
+ var yes = new StringContent ( "y" ) ;
93
+ if ( torrentFlags . HasFlag ( NyaaTorrentFlags . Anonymous ) )
94
+ {
95
+ form . Add ( yes , "is_anonymous" ) ;
96
+ }
97
+ if ( torrentFlags . HasFlag ( NyaaTorrentFlags . Complete ) )
98
+ {
99
+ form . Add ( yes , "is_complete" ) ;
100
+ }
101
+ if ( torrentFlags . HasFlag ( NyaaTorrentFlags . Hidden ) )
102
+ {
103
+ form . Add ( yes , "is_hidden" ) ;
104
+ }
105
+ if ( torrentFlags . HasFlag ( NyaaTorrentFlags . Remake ) )
106
+ {
107
+ form . Add ( yes , "is_remake" ) ;
108
+ }
109
+ }
110
+
87
111
Log . Verbose ( "{Site} formdata content: {@MultipartFormDataContent}" , site , form ) ;
88
112
var result = await httpClient . PostAsyncWithRetry ( postUrl , form ) ;
89
113
var raw = await result . Content . ReadAsStringAsync ( ) ;
@@ -141,5 +165,32 @@ private bool Valid()
141
165
}
142
166
return true ;
143
167
}
168
+
169
+ private NyaaTorrentFlags SetFlags ( List < NyaaTorrentFlags > ? flags , List < ContentTypes > ? tags )
170
+ {
171
+ var flag = NyaaTorrentFlags . None ;
172
+ if ( flags is not null )
173
+ {
174
+ foreach ( var v in flags )
175
+ {
176
+ if ( v == NyaaTorrentFlags . None )
177
+ {
178
+ flag = NyaaTorrentFlags . None ;
179
+ break ;
180
+ }
181
+ flag |= v ;
182
+ }
183
+ }
184
+
185
+ if ( tags is not null )
186
+ {
187
+ if ( tags . Contains ( ContentTypes . Batch ) || tags . Contains ( ContentTypes . Collection ) )
188
+ {
189
+ flag |= NyaaTorrentFlags . Complete ;
190
+ }
191
+ }
192
+
193
+ return flag ;
194
+ }
144
195
}
145
196
}
0 commit comments