[35286] | 1 | #ifndef AMAZON_H |
---|
| 2 | #define AMAZON_H |
---|
| 3 | |
---|
[35296] | 4 | char* amazon_hoster(char* link) |
---|
| 5 | { |
---|
| 6 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
| 7 | |
---|
| 8 | printf("amazon hoster...\n"); |
---|
| 9 | debug(99, "link: %s", link); |
---|
| 10 | char* streamurl = NULL; |
---|
| 11 | |
---|
| 12 | streamurl = hoster(link); |
---|
| 13 | debug(99, "streamurl1: %s", streamurl); |
---|
| 14 | |
---|
| 15 | streamurl = string_replace_all("amp;", "", streamurl, 1); |
---|
| 16 | debug(99, "streamurl2: %s", streamurl); |
---|
| 17 | |
---|
| 18 | return streamurl; |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | char* amazon(char* link) |
---|
| 22 | { |
---|
| 23 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
[35312] | 24 | char* url = NULL, *customerid = NULL, *marketplaceid = NULL, *matchtoken = NULL, *devicetypeid = NULL, *apimain = NULL, *token = NULL; |
---|
[35339] | 25 | char* tmpstr = NULL, *title = NULL, *pic = NULL, *streamurl = NULL, *bitrate = NULL, *random = NULL; |
---|
[35312] | 26 | |
---|
| 27 | unlink("/tmp/amazon_streamurl_get1"); |
---|
| 28 | unlink("/tmp/amazon_streamurl_get2"); |
---|
| 29 | unlink("/tmp/amazon_streamurl_get3"); |
---|
| 30 | unlink("/tmp/amazon_streamurl_get4"); |
---|
| 31 | |
---|
[35302] | 32 | url = ostrcat("http://www.amazon.de/dp/", link, 0, 0); |
---|
| 33 | url = ostrcat(url, "/?_encoding=UTF8", 1, 0); |
---|
[35312] | 34 | |
---|
| 35 | ////////////////////////////////////////////////// |
---|
[35347] | 36 | tmpstr = gethttps(url, NULL); |
---|
| 37 | titheklog(debuglevel, "/tmp/amazon_streamurl_get1", NULL, NULL, NULL, tmpstr); |
---|
[35302] | 38 | free(url), url = NULL; |
---|
[35312] | 39 | ////////////////////////////////////////////////// |
---|
[35296] | 40 | |
---|
[35347] | 41 | customerid = string_resub("\"customerID\":\"", "\"", tmpstr, 0); |
---|
| 42 | marketplaceid = string_resub("\"marketplaceID\":\"", "\"", tmpstr, 0); |
---|
| 43 | matchtoken = string_resub("\"csrfToken\":\"", "\"", tmpstr, 0); |
---|
[35312] | 44 | devicetypeid = ostrcat("A35LWR0L7KC0TJ", NULL, 0, 0); |
---|
[35347] | 45 | free(tmpstr), tmpstr = NULL; |
---|
[35296] | 46 | |
---|
| 47 | // apiMain = ["atv-ps", "atv-ps-eu", "atv-ps-eu"][int(siteVersion)] |
---|
[35312] | 48 | apimain = ostrcat("atv-ps-eu", NULL, 0, 0); |
---|
[35296] | 49 | |
---|
| 50 | url = ostrcat("https://", apimain, 0, 0); |
---|
| 51 | url = ostrcat(url, ".amazon.com/cdp/catalog/GetASINDetails?version=2&format=json&asinlist=", 1, 0); |
---|
[35302] | 52 | url = ostrcat(url, link, 1, 0); |
---|
[35296] | 53 | url = ostrcat(url, "&deviceID=", 1, 0); |
---|
| 54 | url = ostrcat(url, customerid, 1, 0); |
---|
| 55 | url = ostrcat(url, "&includeRestrictions=true&deviceTypeID=", 1, 0); |
---|
| 56 | url = ostrcat(url, devicetypeid, 1, 0); |
---|
| 57 | url = ostrcat(url, "&firmware=WIN%2017,0,0,188%20PlugIn&NumberOfResults=1", 1, 0); |
---|
| 58 | |
---|
| 59 | printf("customerid: %s\n", customerid); |
---|
| 60 | printf("marketplaceid: %s\n", marketplaceid); |
---|
| 61 | printf("matchtoken: %s\n", matchtoken); |
---|
| 62 | printf("devicetypeid: %s\n", devicetypeid); |
---|
| 63 | printf("apimain: %s\n", apimain); |
---|
| 64 | |
---|
[35312] | 65 | ////////////////////////////////////////////////// |
---|
[35347] | 66 | tmpstr = gethttps(url, NULL); |
---|
| 67 | titheklog(debuglevel, "/tmp/amazon_streamurl_get2", NULL, NULL, NULL, tmpstr); |
---|
[35305] | 68 | free(url), url = NULL; |
---|
[35312] | 69 | ////////////////////////////////////////////////// |
---|
[35305] | 70 | |
---|
[35339] | 71 | random = randomstring(18); |
---|
| 72 | url = ostrcat("https://www.amazon.de/gp/video/streaming/player-token.json?callback=jQuery1640", random, 0, 0); |
---|
[35305] | 73 | url = ostrcat(url, "_", 1, 0); |
---|
[35312] | 74 | url = ostrcat(url, olutoa(time(NULL)*1000), 1, 1); |
---|
[35305] | 75 | url = ostrcat(url, "&csrftoken=", 1, 0); |
---|
| 76 | url = ostrcat(url, matchtoken, 1, 0); |
---|
| 77 | url = ostrcat(url, "_", 1, 0); |
---|
[35312] | 78 | url = ostrcat(url, olutoa(time(NULL)*1000), 1, 1); |
---|
| 79 | |
---|
[35347] | 80 | free(tmpstr), tmpstr = NULL; |
---|
| 81 | |
---|
[35312] | 82 | ////////////////////////////////////////////////// |
---|
[35347] | 83 | tmpstr = gethttps(url, NULL); |
---|
| 84 | titheklog(debuglevel, "/tmp/amazon_streamurl_get3", NULL, NULL, NULL, tmpstr); |
---|
[35312] | 85 | free(url), url = NULL; |
---|
| 86 | ////////////////////////////////////////////////// |
---|
[35305] | 87 | |
---|
[35347] | 88 | token = string_resub("\"token\":\"", "\"", tmpstr, 0); |
---|
| 89 | free(tmpstr), tmpstr = NULL; |
---|
| 90 | |
---|
[35312] | 91 | debug(99, "token: %s", token); |
---|
| 92 | |
---|
[35305] | 93 | url = ostrcat("https://", apimain, 0, 0); |
---|
[35312] | 94 | url = ostrcat(url, ".amazon.com/cdp/catalog/GetStreamingUrlSets?version=1&format=json&firmware=WIN%2011,7,700,224%20PlugIn&marketplaceID=", 1, 0); |
---|
| 95 | // trailer |
---|
| 96 | // url = ostrcat(url, ".amazon.com/cdp/catalog/GetStreamingTrailerUrls?version=1&format=json&firmware=WIN%2011,7,700,224%20PlugIn&marketplaceID=", 1, 0); |
---|
[35305] | 97 | url = ostrcat(url, marketplaceid, 1, 0); |
---|
| 98 | url = ostrcat(url, "&token=", 1, 0); |
---|
| 99 | url = ostrcat(url, token, 1, 0); |
---|
| 100 | url = ostrcat(url, "&deviceTypeID=", 1, 0); |
---|
| 101 | url = ostrcat(url, devicetypeid, 1, 0); |
---|
| 102 | url = ostrcat(url, "&asin=", 1, 0); |
---|
| 103 | url = ostrcat(url, link, 1, 0); |
---|
| 104 | url = ostrcat(url, "&customerID=", 1, 0); |
---|
| 105 | url = ostrcat(url, customerid, 1, 0); |
---|
| 106 | url = ostrcat(url, "&deviceID=", 1, 0); |
---|
| 107 | // todo |
---|
[35312] | 108 | // url = ostrcat(url, "A3T8NY6VBAVZZA1441140895392B00HDWUOE0", 1, 0); //'&deviceID='+urllib.quote_plus(matchCID[0].encode("utf8"))+str(int(time.time()*1000))+videoID |
---|
| 109 | url = ostrcat(url, customerid, 1, 0); |
---|
| 110 | url = ostrcat(url, olutoa(time(NULL)*1000), 1, 1); |
---|
| 111 | url = ostrcat(url, link, 1, 0); |
---|
[35305] | 112 | |
---|
[35312] | 113 | ////////////////////////////////////////////////// |
---|
[35347] | 114 | tmpstr = gethttps(url, NULL); |
---|
| 115 | titheklog(debuglevel, "/tmp/amazon_streamurl_get4", NULL, NULL, NULL, tmpstr); |
---|
[35312] | 116 | free(url), url = NULL; |
---|
| 117 | ////////////////////////////////////////////////// |
---|
[35305] | 118 | |
---|
[35347] | 119 | if(tmpstr == NULL || ostrstr(tmpstr, "\"statusCode\":\"ERROR\"") != NULL) |
---|
[35339] | 120 | { |
---|
[35347] | 121 | tmpstr = string_resub("\"message\":\"", "\"", tmpstr, 0); |
---|
[35339] | 122 | textbox(_("Message"), tmpstr , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
| 123 | goto end; |
---|
| 124 | } |
---|
| 125 | |
---|
[35347] | 126 | tmpstr = string_replace_all("{\"bitrate\":", "\n{\"bitrate\":", tmpstr, 1); |
---|
[35305] | 127 | |
---|
[35312] | 128 | int count = 0, i = 0; |
---|
| 129 | struct splitstr* ret1 = NULL; |
---|
| 130 | struct menulist* mlist = NULL, *mbox = NULL; |
---|
[35350] | 131 | ret1 = strsplit(tmpstr, "\n", &count); |
---|
[35312] | 132 | for(i = 0; i < count; i++) |
---|
| 133 | { |
---|
| 134 | if(ostrstr(ret1[i].part, "f4m") != NULL) |
---|
| 135 | pic = ostrcat("f4m.png", NULL, 0, 0); |
---|
| 136 | else if(ostrstr(ret1[i].part, "mp4") != NULL) |
---|
| 137 | pic = ostrcat("mp4.png", NULL, 0, 0); |
---|
| 138 | else if(ostrstr(ret1[i].part, "3gp") != NULL) |
---|
| 139 | pic = ostrcat("3gp.png", NULL, 0, 0); |
---|
| 140 | else if(ostrstr(ret1[i].part, "flv") != NULL) |
---|
| 141 | pic = ostrcat("flv.png", NULL, 0, 0); |
---|
| 142 | bitrate = string_resub("\"bitrate\":", ",", ret1[i].part, 0); |
---|
| 143 | streamurl = string_resub("\"url\":\"", "\"", ret1[i].part, 0); |
---|
| 144 | streamurl = string_replace("rtmpe://azeufms-vodfs.fplive.net/azeufms-vod/mp4:", "http://azeufms-vodfs.fplive.net/", streamurl, 1); |
---|
[35305] | 145 | |
---|
[35312] | 146 | if(ostrstr(streamurl, "http://") != NULL) |
---|
| 147 | { |
---|
| 148 | title = ostrcat("Http Stream (Bitrate ", NULL, 0, 0); |
---|
| 149 | title = ostrcat(title, bitrate, 1, 0); |
---|
| 150 | title = ostrcat(title, ")", 1, 0); |
---|
| 151 | debug(99, "(%d) title: %s streamurl: %s\n", i, title, streamurl); |
---|
| 152 | addmenulist(&mlist, title, streamurl, pic, 0, 0); |
---|
| 153 | } |
---|
| 154 | free(bitrate), bitrate = NULL; |
---|
| 155 | free(title), title = NULL; |
---|
| 156 | free(pic), pic = NULL; |
---|
| 157 | free(streamurl), streamurl = NULL; |
---|
| 158 | } |
---|
| 159 | free(ret1), ret1 = NULL; |
---|
| 160 | |
---|
| 161 | if(mlist != NULL) |
---|
| 162 | { |
---|
| 163 | mbox = menulistbox(mlist, NULL, _("Stream Menu"), _("Choose your Streaming Format from the following list"), NULL, NULL, 1, 0); |
---|
| 164 | if(mbox != NULL) |
---|
| 165 | { |
---|
[35339] | 166 | |
---|
[35312] | 167 | debug(99, "mbox->name %s", mbox->name); |
---|
| 168 | debug(99, "mbox->text %s", mbox->text); |
---|
| 169 | streamurl = ostrcat(mbox->text, NULL, 0, 0); |
---|
| 170 | } |
---|
| 171 | } |
---|
| 172 | |
---|
[35339] | 173 | end: |
---|
| 174 | |
---|
| 175 | free(random), random = NULL; |
---|
[35312] | 176 | free(url), url = NULL; |
---|
| 177 | free(customerid), customerid = NULL; |
---|
| 178 | free(marketplaceid), marketplaceid = NULL; |
---|
| 179 | free(matchtoken), matchtoken = NULL; |
---|
| 180 | free(devicetypeid), devicetypeid = NULL; |
---|
| 181 | free(apimain), apimain = NULL; |
---|
| 182 | free(token), token = NULL; |
---|
[35350] | 183 | printf("11111111\n"); |
---|
[35312] | 184 | free(tmpstr), tmpstr = NULL; |
---|
[35350] | 185 | printf("22222222\n"); |
---|
| 186 | |
---|
[35312] | 187 | free(title), title = NULL; |
---|
| 188 | free(pic), pic = NULL; |
---|
| 189 | free(bitrate), bitrate = NULL; |
---|
| 190 | |
---|
| 191 | debug(99, "streamurl: %s", streamurl); |
---|
[35305] | 192 | return streamurl; |
---|
[35296] | 193 | } |
---|
| 194 | |
---|
[35286] | 195 | int login() |
---|
| 196 | { |
---|
| 197 | int ret = 0; |
---|
| 198 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
| 199 | |
---|
[35347] | 200 | char* hash = NULL, *tmpstr = NULL, *login = NULL; |
---|
[35286] | 201 | |
---|
| 202 | char* user = getconfig("amazon_user", NULL); |
---|
| 203 | char* pass = getconfig("amazon_pass", NULL); |
---|
| 204 | |
---|
| 205 | unlink("/tmp/amazon_tmpstr_get1_blank"); |
---|
| 206 | unlink("/tmp/amazon_tmpstr_get2_sign-in"); |
---|
| 207 | unlink("/tmp/amazon_tmpstr_post1"); |
---|
| 208 | unlink("/tmp/amazon_tmpstr_get3_blank"); |
---|
| 209 | unlink("/tmp/amazon_tmpstr_get4_blank"); |
---|
| 210 | |
---|
| 211 | // logout |
---|
[35339] | 212 | // curlretbuf = gethttps_get("https://www.amazon.de/ap/signin?_encoding=UTF8&openid.assoc_handle=deflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.de%2Fgp%2Fyourstore%2Fhome%3Fie%3DUTF8%26action%3Dsign-out%26path%3D%252Fgp%252Fyourstore%252Fhome%26ref_%3Dnav__gno_signout%26signIn%3D1%26useRedirectOnSuccess%3D1", NULL, debuglevel); |
---|
[35286] | 213 | // titheklog(debuglevel, "/tmp/amazon_tmpstr_get0_logout", NULL, NULL, NULL, curlretbuf); |
---|
| 214 | |
---|
[35347] | 215 | tmpstr = gethttps("https://www.amazon.de/", NULL); |
---|
[35312] | 216 | // debug(99, "tmpstr: %s", curlretbuf); |
---|
[35347] | 217 | titheklog(debuglevel, "/tmp/amazon_tmpstr_get1_blank", NULL, NULL, NULL, tmpstr); |
---|
[35286] | 218 | |
---|
[35347] | 219 | login = string_resub("'config.signOutText',", ");", tmpstr, 0); |
---|
| 220 | free(tmpstr), tmpstr = NULL; |
---|
[35312] | 221 | // debug(99, "login: %s", login); |
---|
[35286] | 222 | strstrip(login); |
---|
[35312] | 223 | // debug(99, "login: %s", login); |
---|
[35286] | 224 | |
---|
| 225 | if(ostrcmp("null", login) == 0) |
---|
| 226 | { |
---|
| 227 | debug(99, "Amazon Login Error"); |
---|
| 228 | ret = 0; |
---|
| 229 | } |
---|
| 230 | else |
---|
| 231 | { |
---|
| 232 | debug(99, "Amazon Login Successful: %s", login); |
---|
| 233 | ret = 1; |
---|
| 234 | } |
---|
| 235 | free(login), login = NULL; |
---|
| 236 | |
---|
| 237 | if(ret == 0) |
---|
| 238 | { |
---|
[35347] | 239 | tmpstr = gethttps("https://www.amazon.de/gp/sign-in.html", NULL); |
---|
| 240 | titheklog(debuglevel, "/tmp/amazon_tmpstr_get2_sign-in", NULL, NULL, NULL, tmpstr); |
---|
[35286] | 241 | |
---|
[35347] | 242 | char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"appActionToken\" value="); |
---|
[35286] | 243 | char* tmp1 = getxmlentry(pos1, "value="); |
---|
| 244 | debug(99, "appActionToken: %s", tmp1); |
---|
| 245 | |
---|
[35347] | 246 | char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"appAction\" value="); |
---|
[35286] | 247 | char* tmp2 = getxmlentry(pos2, "value="); |
---|
| 248 | debug(99, "appActionToken: %s", tmp2); |
---|
| 249 | |
---|
[35347] | 250 | char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"openid.pape.max_auth_age\" value="); |
---|
[35286] | 251 | char* tmp3 = getxmlentry(pos3, "value="); |
---|
| 252 | debug(99, "openid.pape.max_auth_age: %s", tmp3); |
---|
| 253 | |
---|
[35347] | 254 | char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"openid.return_to\" value="); |
---|
[35286] | 255 | char* tmp4 = getxmlentry(pos4, "value="); |
---|
| 256 | debug(99, "openid.return_to: %s", tmp4); |
---|
| 257 | |
---|
[35347] | 258 | char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"prevRID\" value="); |
---|
[35286] | 259 | char* tmp5 = getxmlentry(pos5, "value="); |
---|
| 260 | debug(99, "prevRID: %s", tmp5); |
---|
| 261 | |
---|
[35347] | 262 | char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"openid.identity\" value="); |
---|
[35286] | 263 | char* tmp6 = getxmlentry(pos6, "value="); |
---|
| 264 | debug(99, "openid.identity: %s", tmp6); |
---|
| 265 | |
---|
[35347] | 266 | char* pos7 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"openid.assoc_handle\" value="); |
---|
[35286] | 267 | char* tmp7 = getxmlentry(pos7, "value="); |
---|
| 268 | debug(99, "openid.assoc_handle: %s", tmp7); |
---|
| 269 | |
---|
[35347] | 270 | char* pos8 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"openid.mode\" value="); |
---|
[35286] | 271 | char* tmp8 = getxmlentry(pos8, "value="); |
---|
| 272 | debug(99, "openid.mode: %s", tmp8); |
---|
| 273 | |
---|
[35347] | 274 | char* pos9 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"openid.ns.pape\" value="); |
---|
[35286] | 275 | char* tmp9 = getxmlentry(pos9, "value="); |
---|
| 276 | debug(99, "openid.ns.pape: %s", tmp9); |
---|
| 277 | |
---|
[35347] | 278 | char* pos10 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"openid.claimed_id\" value="); |
---|
[35286] | 279 | char* tmp10 = getxmlentry(pos10, "value="); |
---|
| 280 | debug(99, "openid.claimed_id: %s", tmp10); |
---|
| 281 | |
---|
[35347] | 282 | char* pos11 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"pageId\" value="); |
---|
[35286] | 283 | char* tmp11 = getxmlentry(pos11, "value="); |
---|
| 284 | debug(99, "pageId: %s", tmp11); |
---|
| 285 | |
---|
[35347] | 286 | char* pos12 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"openid.ns\" value="); |
---|
[35286] | 287 | char* tmp12 = getxmlentry(pos12, "value="); |
---|
| 288 | debug(99, "openid.ns: %s", tmp12); |
---|
[35347] | 289 | free(tmpstr), tmpstr = NULL; |
---|
| 290 | |
---|
[35286] | 291 | hash = ostrcat(hash, "appActionToken=", 1, 0); |
---|
| 292 | hash = ostrcat(hash, tmp1, 1, 1); |
---|
| 293 | hash = ostrcat(hash, "&appAction=", 1, 0); |
---|
| 294 | hash = ostrcat(hash, tmp2, 1, 1); |
---|
| 295 | hash = ostrcat(hash, "&openid.pape.max_auth_age=", 1, 0); |
---|
| 296 | hash = ostrcat(hash, tmp3, 1, 1); |
---|
| 297 | hash = ostrcat(hash, "&openid.return_to=", 1, 0); |
---|
| 298 | hash = ostrcat(hash, tmp4, 1, 1); |
---|
| 299 | hash = ostrcat(hash, "&prevRID=", 1, 0); |
---|
| 300 | hash = ostrcat(hash, tmp5, 1, 1); |
---|
| 301 | hash = ostrcat(hash, "&openid.identity=", 1, 0); |
---|
| 302 | hash = ostrcat(hash, tmp6, 1, 1); |
---|
| 303 | hash = ostrcat(hash, "&openid.assoc_handle=", 1, 0); |
---|
| 304 | hash = ostrcat(hash, tmp7, 1, 1); |
---|
| 305 | hash = ostrcat(hash, "&openid.mode=", 1, 0); |
---|
| 306 | hash = ostrcat(hash, tmp8, 1, 1); |
---|
| 307 | hash = ostrcat(hash, "&openid.ns.pape=", 1, 0); |
---|
| 308 | hash = ostrcat(hash, tmp9, 1, 1); |
---|
| 309 | hash = ostrcat(hash, "&openid.claimed_id=", 1, 0); |
---|
| 310 | hash = ostrcat(hash, tmp10, 1, 1); |
---|
| 311 | hash = ostrcat(hash, "&pageId=", 1, 0); |
---|
| 312 | hash = ostrcat(hash, tmp11, 1, 1); |
---|
| 313 | hash = ostrcat(hash, "&openid.ns=", 1, 0); |
---|
| 314 | hash = ostrcat(hash, tmp12, 1, 1); |
---|
| 315 | hash = ostrcat(hash, "&email=", 1, 0); |
---|
| 316 | hash = ostrcat(hash, user, 1, 1); |
---|
| 317 | hash = ostrcat(hash, "&create=0", 1, 0); |
---|
| 318 | hash = ostrcat(hash, "&password=", 1, 0); |
---|
| 319 | hash = ostrcat(hash, pass, 1, 1); |
---|
| 320 | |
---|
[35347] | 321 | tmpstr = gethttps("https://www.amazon.de/ap/signin", hash); |
---|
| 322 | // debug(99, "ret=%s", tmpstr); |
---|
| 323 | titheklog(debuglevel, "/tmp/amazon_tmpstr_post1", NULL, NULL, NULL, tmpstr); |
---|
| 324 | free(tmpstr), tmpstr = NULL; |
---|
| 325 | |
---|
| 326 | tmpstr = gethttps("https://www.amazon.de/", NULL); |
---|
| 327 | // debug(99, "tmpstr: %s", tmpstr); |
---|
| 328 | titheklog(debuglevel, "/tmp/amazon_tmpstr_get3_blank", NULL, NULL, NULL, tmpstr); |
---|
| 329 | free(tmpstr), tmpstr = NULL; |
---|
| 330 | |
---|
| 331 | tmpstr = gethttps("https://www.amazon.de/", NULL); |
---|
[35312] | 332 | // debug(99, "tmpstr: %s", curlretbuf); |
---|
[35347] | 333 | titheklog(debuglevel, "/tmp/amazon_tmpstr_get4_blank", NULL, NULL, NULL, tmpstr); |
---|
| 334 | free(tmpstr), tmpstr = NULL; |
---|
[35286] | 335 | |
---|
[35347] | 336 | login = string_resub("'config.signOutText',", ");", tmpstr, 0); |
---|
[35312] | 337 | // debug(99, "login: %s", login); |
---|
[35286] | 338 | strstrip(login); |
---|
[35312] | 339 | // debug(99, "login: %s", login); |
---|
[35347] | 340 | free(tmpstr), tmpstr = NULL; |
---|
[35286] | 341 | |
---|
| 342 | if(ostrcmp("null", login) == 0) |
---|
| 343 | { |
---|
| 344 | debug(99, "Amazon Login Error"); |
---|
| 345 | ret = 0; |
---|
| 346 | } |
---|
| 347 | else |
---|
| 348 | { |
---|
| 349 | debug(99, "Amazon Login Successful: %s", login); |
---|
| 350 | ret = 1; |
---|
| 351 | } |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | return ret; |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | int amazon_search(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag) |
---|
| 358 | { |
---|
| 359 | int ret = 1; |
---|
| 360 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
| 361 | |
---|
| 362 | if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL) |
---|
| 363 | return ret; |
---|
| 364 | |
---|
[35395] | 365 | char* tmpstr2 = NULL, *tmpstr3 = NULL, *filename = NULL, *tmpstr = NULL, *search = NULL, *line = NULL, *url = NULL, *id = NULL, *streamurl = NULL, *pic = NULL, *year = NULL, *runtime = NULL, *menu = NULL; |
---|
[35286] | 366 | |
---|
[35395] | 367 | tmpstr2 = ostrcat(tmpstr2, "_get", 1, 0); |
---|
[35286] | 368 | |
---|
[35395] | 369 | if(flag == 0 || flag == 1) |
---|
| 370 | { |
---|
[35286] | 371 | if(searchstr == NULL) |
---|
| 372 | search = textinputhist(_("Search"), " ", "searchhist"); |
---|
| 373 | else |
---|
| 374 | search = textinputhist(_("Search"), searchstr, "searchhist"); |
---|
| 375 | } |
---|
| 376 | |
---|
[35395] | 377 | int loginret = 0, type = 0; |
---|
[35286] | 378 | loginret = login(); |
---|
| 379 | printf("loginret=%d\n", loginret); |
---|
| 380 | if(loginret == 0) |
---|
[35361] | 381 | textbox(_("Message"), _("Amazon login not successful! Please check Amazon Prime User/Pass in Tithek settings and try again."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 200, 0, 0); |
---|
[35286] | 382 | else |
---|
[35361] | 383 | textbox(_("Message"), _("Amazon Prime login successful!"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 0, 0); |
---|
[35286] | 384 | |
---|
| 385 | if(search != NULL || flag > 0) |
---|
| 386 | { |
---|
| 387 | drawscreen(load, 0, 0); |
---|
| 388 | search = stringreplacechar(search, ' ', '+'); |
---|
[35395] | 389 | if(flag == 0) |
---|
| 390 | { |
---|
| 391 | filename = ostrcat("movie", NULL, 0, 0); |
---|
| 392 | type = 75; |
---|
| 393 | url = ostrcat("http://www.amazon.de/mn/search/ajax/?_encoding=UTF8&url=node%3D3356018031&field-keywords=", search, 0, 0); |
---|
| 394 | } |
---|
| 395 | else if(flag == 1) |
---|
| 396 | { |
---|
| 397 | filename = ostrcat("season", NULL, 0, 0); |
---|
| 398 | type = 78; |
---|
| 399 | url = ostrcat("http://www.amazon.de/mn/search/ajax/?_encoding=UTF8&url=node%3D3356019031&field-keywords=", search, 0, 0); |
---|
| 400 | } |
---|
| 401 | else if(flag == 2) |
---|
| 402 | { |
---|
| 403 | filename = ostrcat("episode", NULL, 0, 0); |
---|
| 404 | type = 75; |
---|
| 405 | url = ostrcat("http://www.amazon.de/dp/", link, 0, 0); |
---|
| 406 | url = ostrcat(url, "/?_encoding=UTF8", 1, 0); |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | tmpstr2 = ostrcat("/tmp/amazon_search_tmpstr_get", filename, 0, 0); |
---|
| 410 | unlink(tmpstr2); |
---|
| 411 | |
---|
| 412 | tmpstr3 = ostrcat(tmpstr3, "_replace", 1, 0); |
---|
| 413 | unlink(tmpstr3); |
---|
| 414 | |
---|
[35326] | 415 | /////////////////////////// |
---|
| 416 | debug(99, "url: %s", url); |
---|
[35347] | 417 | tmpstr = gethttps(url, NULL); |
---|
[35395] | 418 | titheklog(debuglevel, tmpstr2, NULL, NULL, NULL, tmpstr); |
---|
[35326] | 419 | free(url), url = NULL; |
---|
| 420 | /////////////////////////// |
---|
| 421 | |
---|
[35293] | 422 | int count1 = 0; |
---|
| 423 | int j = 0; |
---|
| 424 | |
---|
| 425 | // tmpstr2 = string_resub("\"value\" : \"<div id=\\\"centerMinus\\\"", "\"tagId\" : \"centerMinus\"", curlretbuf, 0); |
---|
| 426 | // tmpstr2 = string_resub("\"value\" : \"<div id=\\\"centerBelowPlus\\\"", "\"tagId\" : \"centerBelowPlus\"", curlretbuf, 0); |
---|
| 427 | |
---|
[35395] | 428 | if(flag == 0 || flag == 1) |
---|
| 429 | tmpstr = string_replace_all("<li id=\\\"result_", "\n<li id=\\\"result_", tmpstr, 1); |
---|
| 430 | else |
---|
| 431 | { |
---|
| 432 | tmpstr = string_replace_all("\n", " ", tmpstr, 1); |
---|
| 433 | tmpstr = string_replace_all("<li class=\"selected-episode", "\n<li class=\"\">", tmpstr, 1); |
---|
| 434 | tmpstr = string_replace_all("<li class=\"\">", "\n<li class=\"\">", tmpstr, 1); |
---|
| 435 | tmpstr = string_replace_all("<li class=\"last-episode", "\n<li class=\"last-episode", tmpstr, 1); |
---|
| 436 | } |
---|
| 437 | titheklog(debuglevel, tmpstr3, NULL, NULL, NULL, tmpstr); |
---|
| 438 | |
---|
[35293] | 439 | count1 = 0; |
---|
| 440 | j = 0; |
---|
| 441 | struct splitstr* ret1 = NULL; |
---|
[35347] | 442 | ret1 = strsplit(tmpstr, "\n", &count1); |
---|
[35293] | 443 | int incount = 0; |
---|
| 444 | |
---|
| 445 | if(ret1 != NULL && count1 > 0) |
---|
| 446 | { |
---|
| 447 | int max = count1; |
---|
| 448 | for(j = 0; j < max; j++) |
---|
| 449 | { |
---|
| 450 | if(ostrstr(ret1[j].part, "result_") != NULL) |
---|
| 451 | { |
---|
[35395] | 452 | printf("(%d) ret1[j].part: %s\n", j, ret1[j].part); |
---|
[35293] | 453 | streamurl = string_resub("\" href=\\\"", "\\\">", ret1[j].part, 0); |
---|
| 454 | pic = string_resub("\" src=\\\"", "\\\"", ret1[j].part, 0); |
---|
[35395] | 455 | if(pic == NULL) |
---|
| 456 | pic = ostrcat(pic, "http://atemio.dyndns.tv/mediathek/menu/default.jpg", 1, 0); |
---|
[35293] | 457 | title = string_resub("\" title=\\\"", "\\\"", ret1[j].part, 0); |
---|
| 458 | year = string_resub("<span class=\\\"a-size-small a-color-secondary\\\">", "</span>", ret1[j].part, 0); |
---|
| 459 | runtime = oregex(".*a-size-small a-color-secondary.*>(.*)</span>.*", ret1[j].part); |
---|
[35296] | 460 | id = oregex("http.*//.*/.*/(.*)/ref.*", streamurl); |
---|
[35395] | 461 | } |
---|
| 462 | else if(ostrstr(ret1[j].part, "<li class=\"\">") != NULL) |
---|
| 463 | { |
---|
| 464 | printf("(%d) ret1[j].part: %s\n", j, ret1[j].part); |
---|
| 465 | streamurl = string_resub("href=\"", "\"", ret1[j].part, 0); |
---|
| 466 | pic = string_resub("src=\"", "\"", ret1[j].part, 0); |
---|
| 467 | if(pic == NULL) |
---|
| 468 | pic = ostrcat(pic, "http://atemio.dyndns.tv/mediathek/menu/default.jpg", 1, 0); |
---|
| 469 | title = string_resub("<span class=\"episode-title\">", "</span>", ret1[j].part, 0); |
---|
| 470 | year = string_resub("<span class=\"dv-badge release-date\">", "</span>", ret1[j].part, 0); |
---|
| 471 | runtime = string_resub("<span class=\"dv-badge runtime\">", "</span>", ret1[j].part, 0); |
---|
| 472 | id = oregex("http.*//.*/.*/(.*)/ref.*", streamurl); |
---|
| 473 | } |
---|
[35293] | 474 | |
---|
[35395] | 475 | if(ostrstr(ret1[j].part, "result_") != NULL || ostrstr(ret1[j].part, "<li class=\"\">") != NULL) |
---|
| 476 | { |
---|
| 477 | debug(99, "(%d) streamurl: %s", j, streamurl); |
---|
[35296] | 478 | free(streamurl), streamurl = NULL; |
---|
| 479 | streamurl = ostrcat("http://www.amazon.de/dp/", id, 0, 0); |
---|
| 480 | streamurl = ostrcat(streamurl, "/?_encoding=UTF8", 1, 0); |
---|
[35395] | 481 | debug(99, "(%d) streamurl changed: %s", j, streamurl); |
---|
| 482 | debug(99, "(%d) id: %s", j, id); |
---|
| 483 | debug(99, "(%d) pic: %s", j, pic); |
---|
| 484 | debug(99, "(%d) title: %s", j, title); |
---|
| 485 | debug(99, "(%d) year: %s", j, year); |
---|
| 486 | debug(99, "(%d) runtime: %s", j, runtime); |
---|
| 487 | debug(99, "----------------------"); |
---|
[35293] | 488 | |
---|
| 489 | if(streamurl != NULL) |
---|
| 490 | { |
---|
| 491 | incount += 1; |
---|
| 492 | line = ostrcat(line, title, 1, 0); |
---|
| 493 | line = ostrcat(line, " (", 1, 0); |
---|
| 494 | line = ostrcat(line, year, 1, 0); |
---|
| 495 | line = ostrcat(line, ") ", 1, 0); |
---|
| 496 | line = ostrcat(line, runtime, 1, 0); |
---|
| 497 | line = ostrcat(line, "#", 1, 0); |
---|
[35302] | 498 | line = ostrcat(line, id, 1, 0); |
---|
[35395] | 499 | // line = ostrcat(line, streamurl, 1, 0); |
---|
[35293] | 500 | line = ostrcat(line, "#", 1, 0); |
---|
| 501 | line = ostrcat(line, pic, 1, 0); |
---|
| 502 | line = ostrcat(line, "#amazon_search_", 1, 0); |
---|
[35395] | 503 | line = ostrcat(line, oitoa(incount + time(NULL)), 1, 1); |
---|
| 504 | line = ostrcat(line, ".jpg#Amazon - Search#", 1, 0); |
---|
| 505 | line = ostrcat(line, oitoa(type), 1, 1); |
---|
| 506 | line = ostrcat(line, "\n", 1, 0); |
---|
[35293] | 507 | } |
---|
| 508 | |
---|
[35296] | 509 | free(id), id = NULL; |
---|
[35293] | 510 | free(streamurl), streamurl = NULL; |
---|
| 511 | free(pic), pic = NULL; |
---|
| 512 | free(title), title = NULL; |
---|
| 513 | free(year), year = NULL; |
---|
| 514 | free(runtime), runtime = NULL; |
---|
| 515 | } |
---|
| 516 | } |
---|
| 517 | } |
---|
[35347] | 518 | free(ret1), ret1 = NULL; |
---|
| 519 | free(tmpstr), tmpstr = NULL; |
---|
[35293] | 520 | |
---|
| 521 | if(line != NULL) |
---|
| 522 | { |
---|
[35395] | 523 | printf("line: %s\n", line); |
---|
| 524 | menu = ostrcat("/tmp/tithek/amazon.", NULL, 0, 0); |
---|
| 525 | menu = ostrcat(menu, filename, 1, 0); |
---|
| 526 | menu = ostrcat(menu, ".list", 1, 0); |
---|
[35293] | 527 | writesys(menu, line, 0); |
---|
| 528 | struct tithek* tnode = (struct tithek*)listbox->select->handle; |
---|
| 529 | createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag); |
---|
| 530 | ret = 0; |
---|
| 531 | } |
---|
| 532 | |
---|
| 533 | /* |
---|
| 534 | int i = 0, len = 0, treffer = 0, amazontoken = 1000; |
---|
| 535 | jsmn_parser parser; |
---|
| 536 | // jsmntok_t tokens[FACEMAXTOKEN]; //TODO |
---|
| 537 | jsmntok_t tokens[amazontoken]; //TODO |
---|
| 538 | char* buf = NULL; |
---|
| 539 | |
---|
| 540 | if(buf == NULL) |
---|
| 541 | { |
---|
| 542 | err("no mem"); |
---|
| 543 | free(curlretbuf); curlretbuf = NULL; |
---|
| 544 | curlretbufsize = 0; |
---|
| 545 | return 1; |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | jsmn_init(&parser); |
---|
| 549 | |
---|
| 550 | // ret = jsmn_parse(&parser, curlretbuf, tokens, FACEMAXTOKEN); |
---|
| 551 | int ret1 = jsmn_parse(&parser, curlretbuf, tokens, amazontoken); |
---|
| 552 | if(ret1 == JSMN_SUCCESS) |
---|
| 553 | { |
---|
| 554 | for(i = 0; i < amazontoken; i++) |
---|
| 555 | { |
---|
| 556 | if(tokens[i].start == -1) break; |
---|
| 557 | |
---|
| 558 | len = tokens[i].end - tokens[i].start; |
---|
| 559 | if(len > MINMALLOC) len = MINMALLOC; |
---|
| 560 | char* ptr = curlretbuf + tokens[i].start; |
---|
| 561 | |
---|
| 562 | printf("tokens[i].type=%d ptr=%s buf=%s\n", tokens[i].type, ptr, buf); |
---|
| 563 | } |
---|
| 564 | } |
---|
| 565 | */ |
---|
| 566 | /////// |
---|
[35286] | 567 | } |
---|
| 568 | |
---|
[35395] | 569 | free(filename), filename = NULL; |
---|
[35326] | 570 | free(menu), menu = NULL; |
---|
| 571 | free(runtime), runtime = NULL; |
---|
| 572 | free(year), year = NULL; |
---|
| 573 | free(title), title = NULL; |
---|
| 574 | free(pic), pic = NULL; |
---|
| 575 | free(streamurl), streamurl = NULL; |
---|
| 576 | free(id), id = NULL; |
---|
[35395] | 577 | free(tmpstr2), tmpstr2 = NULL; |
---|
| 578 | free(tmpstr3), tmpstr3 = NULL; |
---|
[35326] | 579 | free(line), line = NULL; |
---|
| 580 | free(streamurl), streamurl = NULL; |
---|
| 581 | free(pic), pic = NULL; |
---|
| 582 | free(title), title = NULL; |
---|
| 583 | free(year), year = NULL; |
---|
| 584 | free(runtime), runtime = NULL; |
---|
[35286] | 585 | free(search), search = NULL; |
---|
[35326] | 586 | |
---|
[35286] | 587 | return ret; |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | int amazon_search_local(struct skin* grid, struct skin* listbox, struct skin* countlabel, struct skin* load, char* link, char* title, char* searchstr, int flag) |
---|
| 591 | { |
---|
| 592 | char* tmpstr = NULL, *tmpstr1 = NULL, *line = NULL, *menu = NULL, *search = NULL; |
---|
| 593 | int ret = 1, count = 0, i = 0; |
---|
| 594 | |
---|
| 595 | if(listbox == NULL || listbox->select == NULL || listbox->select->handle == NULL) |
---|
| 596 | return ret; |
---|
| 597 | |
---|
| 598 | if(searchstr == NULL) |
---|
| 599 | search = textinputhist(_("Search"), " ", "searchhist"); |
---|
| 600 | else |
---|
| 601 | search = textinputhist(_("Search"), searchstr, "searchhist"); |
---|
| 602 | |
---|
| 603 | if(search != NULL) |
---|
| 604 | { |
---|
| 605 | drawscreen(load, 0, 0); |
---|
| 606 | |
---|
| 607 | strstrip(search); |
---|
| 608 | string_tolower(search); |
---|
| 609 | |
---|
| 610 | tmpstr = gethttp("atemio.dyndns.tv", "/mediathek/amazon/streams/amazon.all-sorted.list", 80, NULL, HTTPAUTH, 5000, NULL, 0); |
---|
| 611 | |
---|
| 612 | struct splitstr* ret1 = NULL; |
---|
| 613 | ret1 = strsplit(tmpstr, "\n", &count); |
---|
| 614 | |
---|
| 615 | if(ret1 != NULL) |
---|
| 616 | { |
---|
| 617 | int max = count; |
---|
| 618 | for(i = 0; i < max; i++) |
---|
| 619 | { |
---|
| 620 | |
---|
| 621 | tmpstr1 = ostrcat(ret1[i].part, NULL, 0, 0); |
---|
| 622 | tmpstr1 = stringreplacecharonce(tmpstr1, '#', '\0'); |
---|
| 623 | string_tolower(tmpstr1); |
---|
| 624 | |
---|
| 625 | if(ostrstr(tmpstr1, search) != NULL) |
---|
| 626 | { |
---|
| 627 | printf("found: %s\n", ret1[i].part); |
---|
| 628 | int rcret = waitrc(NULL, 10, 0); |
---|
| 629 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
| 630 | |
---|
| 631 | line = ostrcat(line, ret1[i].part, 1, 0); |
---|
| 632 | line = ostrcat(line, "\n", 0, 0); |
---|
| 633 | } |
---|
| 634 | free(tmpstr1), tmpstr1 = NULL; |
---|
| 635 | } |
---|
| 636 | free(ret1), ret1 = NULL; |
---|
| 637 | |
---|
| 638 | if(line != NULL) |
---|
| 639 | { |
---|
| 640 | line = string_replace_all("http://atemio.dyndns.tv/", "http://imageshack.us/md/up/grd/", line, 1); |
---|
| 641 | menu = ostrcat("/tmp/tithek/amazon.search.list", NULL, 0, 0); |
---|
| 642 | writesys(menu, line, 0); |
---|
| 643 | struct tithek* tnode = (struct tithek*)listbox->select->handle; |
---|
| 644 | createtithek(tnode, tnode->title, menu, tnode->pic, tnode->localname, tnode->menutitle, tnode->flag); |
---|
| 645 | ret = 0; |
---|
| 646 | } |
---|
| 647 | } |
---|
| 648 | free(tmpstr), tmpstr = NULL; |
---|
| 649 | } |
---|
| 650 | free(search), search = NULL; |
---|
[35313] | 651 | |
---|
[35286] | 652 | return ret; |
---|
| 653 | } |
---|
| 654 | |
---|
| 655 | #endif |
---|