Plugin Directory

Changeset 2310925


Ignore:
Timestamp:
05/23/2020 10:22:01 PM (6 years ago)
Author:
sjhoo
Message:

instagram issue has been resolved

Location:
wsm-downloader/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wsm-downloader/trunk/dl_engine/instagram/decoder.php

    r2217953 r2310925  
    11<?php
    2 
    3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    4 
    52class instagram {
    63    function decoder($url) {
    74        $msg['success'] = false;
    85        $msg['body'] = 'Seems like there is nothing here!';
    9         $data = wsmd_file_get_content($url);
    10         libxml_use_internal_errors(true);
    11         $doc = new DomDocument();
    12         $doc->loadHTML($data);
    13         $xpath = new DOMXPath($doc);
    14         $query = '//*/meta[starts-with(@property, \'og:\')]';
    15         $metas = $xpath->query($query);
    16         foreach ($metas as $meta) {
     6       
     7        $fixed_url = explode('?' , $url);
     8        $url = rtrim($fixed_url[0] , '/');
     9       
     10        $data0 = json_decode(wsmd_file_get_content('https://api.instagram.com/oembed/?url='.$url));
     11       
     12        if(isset($data0->title)){
     13            $msg['title'] = $data0->title;
     14            $msg['thumnail_src'] = $data0->thumbnail_url;
    1715            $msg['success'] = true;
    18             unset($msg['body']);
    19             $property = $meta->getAttribute('property');
    20             $content = $meta->getAttribute('content');
    21             if ($property == 'og:title') {
    22                 $msg['title'] = explode("Instagram:" , $content)[1];
    23             }
    24             if ($property == 'og:image') {
    25                 $msg['thumnail_src'] = $content;
    26             }
    27             if ($property == 'og:video:secure_url') {
    28                 $src = $content;
     16                    $src = $data0->thumbnail_url;
     17                    $quality = $data0->thumbnail_width . 'x' . $data0->thumbnail_height;
     18                    $type_p = pathinfo(explode("?" , $src)[0], PATHINFO_EXTENSION);
     19                    $msg['photo'][] = ['direct_url' => $src, 'feu_url' => $src, 'type' => $type_p, 'quality' => $quality, 'size' => wsmd_get_file_size($src), ];           
     20        }
     21       
     22        $data = wsmd_file_get_content($url.'/embed/captioned/');
     23         
     24        ////////aditional info extractor
     25        $json_file = $this->get_string_between($data, "window.__additionalDataLoaded('graphql',", ');');
     26        $parsed_json = json_decode($json_file);
     27        $post_page[0] = $parsed_json;
     28       
     29       
     30           
     31               
     32           if(isset($post_page[0]->shortcode_media->display_url)){
     33               unset($msg['photo']);
     34            $msg['thumnail_src'] = $post_page[0]->shortcode_media->display_url;
     35            $msg['success'] = true;
     36                    $src = $post_page[0]->shortcode_media->display_url;
     37                    $quality = $data0->thumbnail_width . 'x' . $data0->thumbnail_height;
     38                    $type_p = pathinfo(explode("?" , $src)[0], PATHINFO_EXTENSION);
     39                    $msg['photo'][] = ['direct_url' => $src, 'feu_url' => $src, 'type' => $type_p, 'quality' => $quality, 'size' => wsmd_get_file_size($src), ];               
     40           }
     41           
     42               
     43           if(isset($post_page[0]->shortcode_media->video_url)){
     44                $src = $post_page[0]->shortcode_media->video_url;
    2945                $type = pathinfo(explode("?" , $src)[0], PATHINFO_EXTENSION);
    3046                $msg['streams'][] = ['direct_url' => $src, 'feu_url' => $src, 'type' => $type, 'quality' => 'HQ', 'size' => wsmd_get_file_size($src), ];
    31             }
    32         }
    33         ////////aditional info extractor
    34         $json_file = $this->get_string_between($data, 'window._sharedData = {', '};');
    35         $parsed_json = json_decode("{" . $json_file . "}");
    36         $post_page = $parsed_json->entry_data->PostPage;
    37         if (!empty($post_page[0]->graphql->shortcode_media->edge_sidecar_to_children)) {
    38             $childrens = $post_page[0]->graphql->shortcode_media->edge_sidecar_to_children->edges;
     47           }
     48       
     49
     50        if (!empty($post_page[0]->shortcode_media->edge_sidecar_to_children)) {
     51            $childrens = $post_page[0]->shortcode_media->edge_sidecar_to_children->edges;
    3952            foreach ($childrens as $child) {
    4053                $child_node = $child->node;
     
    5366
    5467
    55        if(empty($msg['photo']) and !empty($post_page[0]->graphql->shortcode_media->display_resources)){
    56         $resurces = $post_page[0]->graphql->shortcode_media->display_resources;
     68       if(empty($msg['photo']) and !empty($post_page[0]->shortcode_media->display_resources)){
     69        $resurces = $post_page[0]->shortcode_media->display_resources;
    5770        foreach($resurces as $resurce){
    5871                    $src = $resurce->src;
     
    6275        }
    6376       }
     77       
     78if(empty($msg['photo'][1]) and strpos($data , 'srcset') !== false){   
     79$first_extract = $this->get_string_between(str_replace('&amp;' , '&' , $data) , '<img class="EmbeddedMediaImage"' , '/>');
     80$second = $this->get_string_between($first_extract , 'srcset="' , '"');
     81$exloded = explode("," , $second);
     82foreach($exloded as $explod1){
     83    $extract = explode(' ' , $explod1);
     84    $msg['photo'][] = ['direct_url' => $extract[0], 'feu_url' => $extract[0], 'type' => 'jpg' , 'quality' => $extract[1], 'size' => wsmd_get_file_size($extract[0]), ];
     85}     
     86       
     87}
    6488       
    6589        return json_encode($msg);
    6690    }
    67    
    6891   
    6992    function get_string_between($string, $start, $end) {
     
    7497        $len = strpos($string, $end, $ini) - $ini;
    7598        return substr($string, $ini, $len);
    76     }
     99    }   
     100   
     101           
    77102}
  • wsm-downloader/trunk/readme.txt

    r2218078 r2310925  
    44Donate link: https://ttmga.com
    55Requires at least: 4.9
    6 Tested up to: 5.3.2
     6Tested up to: 5.4.1
    77Requires PHP: 7.0
    88Stable tag: trunk
     
    146146Released into the wordpress
    147147
     148=1.1.0=
     149Instagram downloader issue has been solved
     150
    148151
    149152
     
    151154
    152155=1.0.0=
     156Just released into the WordPress
    153157
    154 Just released into the WordPress
     158=1.0.0=
     159Instagram downloader issue has been solved
  • wsm-downloader/trunk/wsm_downloader.php

    r2217953 r2310925  
    55 * Author: S.J.Hossseini
    66 * Author URI: https://t.me/ttmga
    7  * Version: 1.0.0
     7 * Version: 1.1.0
    88 * Text Domain: wsm-downloader
    99 * Domain Path: /languages
     
    1616    define('WSMD_PLUGIN_FILE', plugin_dir_path(__FILE__));
    1717    define('WSMD_PLUGIN_URL', plugins_url('', __FILE__));
    18     define('WSMD_SCRIPT_VERSION', '1.0.1');
     18    define('WSMD_SCRIPT_VERSION', '1.1.1');
    1919  }
    2020 
     
    171171$defaults["shortcode"]["form"]["button"]["border-style"] = "solid" ;
    172172$defaults["shortcode"]["form"]["button"]["border-radius"] = "0" ;
    173 $defaults["shortcode"]["preloader"] = WSMD_PLUGIN_URL.'/assets/img/preloader.gif' ;
     173$defaults["shortcode"]["preloader"] = str_replace('_' , '-' , WSMD_PLUGIN_URL).'/assets/img/preloader.gif' ;
    174174$defaults["shortcode"]["modal"]["active"] = "on" ;
    175175$defaults["shortcode"]["modal"]["ads1"] = "" ;
Note: See TracChangeset for help on using the changeset viewer.