Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trycf/671ae440f6c04762331bf29532dec064 to your computer and use it in GitHub Desktop.
Save trycf/671ae440f6c04762331bf29532dec064 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfhttp url="https://api2.ottplay.com/api/v4.6/web/movie?limit=10&page=1&release_status=released&device_id=b7161536-44a7-435b-89e0-4a93f4bfd79a" method="get" result="aaa">
</cfhttp>
<cfset moviesaar = DeserializeJSON(aaa.Filecontent)>
<cfset news = queryNew("Id,Type,Title,OttReleaseDate,OTTPlatform,Description,Actor,Director,Genre", "varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar")>
<cfloop index="i" from="1" to="#arrayLen(moviesaar.movies)#">
<cfset appurl = "https://www.ottplay.com/#moviesaar.movies[i].permalink#">
<cfhttp url="#appurl#" method="GET" result="aa" timeout="15"/>
<cfset pageData = aa.FileContent>
<cfset strpos = FindNoCase('<script type="application/ld+json">{"@context":"https://schema.org","@type":"Movie"', pageData) + 35>
<cfset strdata = RemoveChars(pageData, 1, strpos)>
<cfset endPos = find("</script>", strdata)>
<cfoutput>
<!--- #HTMLEditFormat(mid(aa.Filecontent, strpos, endPos))# --->
<cftry>
<cfset jsondata = DeserializeJSON(mid(aa.Filecontent, strpos, endPos))>
<!--- <cfdump var="#jsondata#"> --->
<cfset queryAddRow(news)>
<cfset querySetCell(news, "id", jsondata.url)>
<cfset querySetCell(news, "Type", jsondata['@type'])>
<cfset querySetCell(news, "Title", jsondata.name)>
<cfset innerhtmlpos = FindNoCase('<div class="movieDescription_pageHeadMp__UlfUz">', pageData) + 51>
<cfset innerhtmldata = RemoveChars(pageData, 1, innerhtmlpos)>
<cfset innerhtmlpos = FindNoCase('Release date : </b><span>', innerhtmldata) + 24>
<cfset innerhtmldata2 = RemoveChars(innerhtmldata, 1, innerhtmlpos)>
<cfset innerhtmlloc = FindNoCase('</span></div>', innerhtmldata2) - 1>
<cfset querySetCell(news, "OttReleaseDate", Left(innerhtmldata2, innerhtmlloc))>
<cfset innerhtmlpos = FindNoCase('<div class="jss175"><b>Platforms : </b>On <span class="jss176 ">', innerhtmldata2) + 63>
<cfset innerhtmldata2 = RemoveChars(innerhtmldata2, 1, innerhtmlpos)>
<cfset innerhtmlloc = FindNoCase('</span></div>', innerhtmldata2) - 1>
<cfset ottplatformname = Left(innerhtmldata2, innerhtmlloc)>
<cfif len(ottplatformname) GT 100>
<cfset querySetCell(news, "OTTPlatform", "This title is currently not available for streaming")>
<cfelse>
<cfset querySetCell(news, "OTTPlatform", ottplatformname)>
</cfif>
<cfset querySetCell(news, "Description", jsondata.description)>
<cfif arrayLen(jsondata.actor)>
<cfset actorlist = "">
<cfloop index="j" from="1" to="#arrayLen(jsondata.actor)#">
<cfset actorlist = listAppend(actorlist,jsondata.actor[j].name)>
</cfloop>
<cfset querySetCell(news, "Actor", actorlist)>
</cfif>
<cfset querySetCell(news, "Director", jsondata.director.name)>
<cfif arrayLen(jsondata.genre)>
<cfset querySetCell(news, "Genre", arrayToList(jsondata.genre))>
</cfif>
<cfcatch>
</cfcatch>
</cftry>
</cfoutput>
</cfloop>
<cfdump var="#news#">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment