@@ -14,6 +14,22 @@ class GooglePlay {
1414 private $ input = '' ; // content retrieved from remote
1515 private $ lastError = '' ;
1616
17+ /** Turn debug mode on or off
18+ * @method public setDebug
19+ * @param bool debug turn debug mode on (true) or off (false)
20+ */
21+ public function setDebug ($ debug ) {
22+ $ this ->debug = (bool ) $ debug ;
23+ }
24+
25+ /** Check whether debug mode is enabled
26+ * @method public getDebug
27+ * @return bool debug whether debug mode is turned on (true) or off (false)
28+ */
29+ public function getDebug () {
30+ return $ this ->debug ;
31+ }
32+
1733 /** Parse a given RegEx and return the match marked by '(?<content>)'
1834 * @method protected getRegVal
1935 * @param string regEx regular expression to parse
@@ -85,6 +101,10 @@ public function parseApplication($packageName, $lang='en_US', $loc='US') {
85101
86102 $ values ["summary " ] = '' ;
87103 $ values ["description " ] = $ this ->getRegVal ('/itemprop="description"><span jsslot><div jsname="sngebd">(?<content>.*?)<\/div><\/span><div/i ' );
104+ if ( strtolower (substr ($ lang ,0 ,2 )) != 'en ' ) { // Google sometimes keeps the EN description additionally, so we need to filter it out
105+ if ($ this ->debug ) echo "Original Description: \n" . $ values ["description " ] . "\n\n" ;
106+ $ values ["description " ] = preg_replace ('!.*?<div jsname="Igi1ac" style="display:none;">(.+)!ims ' , '$1 ' , $ values ["description " ]);
107+ }
88108 $ values ["icon " ] = $ this ->getRegVal ('/<div class="hkhL9e"><div class="xSyT2c"><img src="(?<content>[^\"]+)"/i ' );
89109 $ values ["featureGraphic " ] = preg_replace ('!(.*)=w\d+.*!i ' , '$1 ' , $ this ->getRegVal ('/<meta name="twitter:image" content="(?<content>[^\"]+)"/i ' ));
90110
@@ -233,6 +253,26 @@ public function parsePerms($packageName, $lang='en') {
233253 return ['success ' =>1 , 'grouped ' =>$ perms , 'perms ' =>array_unique ($ perms_unique )];
234254 }
235255
256+ /** Obtain list of top apps
257+ * @method public parseTopApps
258+ * @param string category name of the category to parse
259+ * @return array array of package names
260+ */
261+ public function parseTopApps () {
262+ $ link = "https://play.google.com/store/apps/top " ;
263+ return $ this ->parse ($ link );
264+ }
265+
266+ /** Obtain list of newest apps
267+ * @method public parseNewApps
268+ * @param string category name of the category to parse
269+ * @return array array of package names
270+ */
271+ public function parseNewApps () {
272+ $ link = "https://play.google.com/store/apps/new " ;
273+ return $ this ->parse ($ link );
274+ }
275+
236276 /** Parse Play Store page for a given category and return package names
237277 * use this::parseCategories to obtain a list of available categories
238278 * @method public parseCategory
@@ -268,6 +308,20 @@ public function parseSimilar($packageName) {
268308 return $ this ->parse ($ input , false );
269309 }
270310
311+ /** Obtain list of other apps by same author
312+ * @method parseOthers
313+ * @param string packageName package name of the app to find similars for, e.g. 'com.example.app'
314+ * @return array array of package names
315+ */
316+ public function parseOthers ($ packageName ) {
317+ if ( ! $ this ->getApplicationPage ($ packageName ) )
318+ return ['success ' =>0 ,'message ' =>$ this ->lastError ];
319+ $ input = $ this ->getRegVal ('!<h2 class="sv0AUd bs3Xnd">More by [^<]*</h2></a></div><div class="W9yFB">(?<content>.+?)</c-data></c-wiz></div></div></div><script!ims ' );
320+ if ( empty ($ input ) )
321+ return ['success ' =>0 ,'message ' =>'no data found ' ];
322+ return $ this ->parse ($ input , false );
323+ }
324+
271325 /** Search for apps by a given string
272326 * @method public parseSearch
273327 * @param string query string to search for
0 commit comments