ZMediumToMarkdown 2.4.9 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/Post.rb +1 -13
- data/lib/Request.rb +20 -17
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 6c16ac0a5062f690cf0d57960b5921599e254c609b249c7e55929f7c925fb89c
         | 
| 4 | 
            +
              data.tar.gz: d571bfe350ecffc3a9ab79028d81fe76383f97c21dc2a46b81a6ccd194623e5f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d0bff21c619bed3182c7142bbf4b8f56cf975314f5d852d0032182715e6ea51a805245e4e490b8d55b21a593c9b983df1b0ec9c975a7e9570e221ccc340df4ef
         | 
| 7 | 
            +
              data.tar.gz: 94574f5cc07a86bd0897efb99538352a664e01483586f102a5440862bf4a90d9907a3868e122f78883e3eafed56e8a0117664037fd33675c66d3fa9929d1ec20
         | 
    
        data/lib/Post.rb
    CHANGED
    
    | @@ -51,19 +51,7 @@ class Post | |
| 51 51 | 
             
                  }
         | 
| 52 52 | 
             
                ]
         | 
| 53 53 |  | 
| 54 | 
            -
                 | 
| 55 | 
            -
                https = Net::HTTP.new(uri.host, uri.port)
         | 
| 56 | 
            -
                https.use_ssl = true
         | 
| 57 | 
            -
                request = Net::HTTP::Post.new(uri)
         | 
| 58 | 
            -
                request['Content-Type'] = 'application/json'
         | 
| 59 | 
            -
                if !$cookie_sid.nil? && !$cookie_uid.nil?
         | 
| 60 | 
            -
                  request['Cookie'] = "sid=#{$cookie_sid}; uid=#{$cookie_uid}"
         | 
| 61 | 
            -
                end
         | 
| 62 | 
            -
                request.body = JSON.dump(query)
         | 
| 63 | 
            -
                response = https.request(request)
         | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
                body = Request.body(response)
         | 
| 54 | 
            +
                body = Request.body(Request.URL("https://medium.com/_/graphql", method = 'POST', data = query));
         | 
| 67 55 | 
             
                if !body.nil?
         | 
| 68 56 | 
             
                  json = JSON.parse(body)
         | 
| 69 57 | 
             
                  json&.dig(0, "data", "post", "viewerEdge", "fullContent")
         | 
    
        data/lib/Request.rb
    CHANGED
    
    | @@ -22,23 +22,26 @@ class Request | |
| 22 22 | 
             
                        end
         | 
| 23 23 | 
             
                    end
         | 
| 24 24 |  | 
| 25 | 
            -
                     | 
| 26 | 
            -
                       | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 25 | 
            +
                    if !$cookie_sid.nil? && !$cookie_uid.nil?
         | 
| 26 | 
            +
                      request['Cookie'] = "sid=#{$cookie_sid}; uid=#{$cookie_uid}";
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    response = https.request(request);
         | 
| 30 | 
            +
                    
         | 
| 31 | 
            +
                    # 3XX Redirect
         | 
| 32 | 
            +
                    if response.code.to_i == 429
         | 
| 33 | 
            +
                      raise "Error: Too Manay Reqeust, blocked by Medium.\n####################\n### Please try again later.\n### Ref: https://zhgchg.li/posts/en-medium-to-jekyll/#paywall-posts-require-a-medium-account-with-access-permissions-and-cookies-author-or-medium-member \n####################\n### ERROR URL: #{url}"
         | 
| 34 | 
            +
                    elsif response.code.to_i >= 300 && response.code.to_i <= 399 && !response['location'].nil? && response['location'] != ''
         | 
| 35 | 
            +
                        if retryCount >= 10
         | 
| 36 | 
            +
                            raise "Error: Retry limit reached. path: #{url}"
         | 
| 37 | 
            +
                        else
         | 
| 38 | 
            +
                            location = response['location']
         | 
| 39 | 
            +
                            if !location.match? /^(http)/
         | 
| 40 | 
            +
                                location = "#{uri.scheme}://#{uri.host}#{location}"
         | 
| 41 | 
            +
                            end
         | 
| 42 | 
            +
                            
         | 
| 43 | 
            +
                            response = self.URL(location, method, data, retryCount)
         | 
| 44 | 
            +
                        end
         | 
| 42 45 | 
             
                    end
         | 
| 43 46 |  | 
| 44 47 | 
             
                    response
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ZMediumToMarkdown
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.5.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - ZhgChgLi
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2025-01- | 
| 11 | 
            +
            date: 2025-01-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: nokogiri
         |