AAndyProgram / SCrawler

🏳️‍🌈 Media downloader from any sites, including Twitter, Reddit, Instagram, Threads, Facebook, OnlyFans, YouTube, Pinterest, PornHub, XHamster, XVIDEOS, ThisVid etc.
https://discord.gg/uFNUXvFFmg
GNU General Public License v3.0
1.23k stars 81 forks source link

[BUG] instagram Hash not able to be auto-filled from cookies #52

Closed TGJ64 closed 2 years ago

TGJ64 commented 2 years ago

I have a suspicion that this is due to instagram changing something on their end again.

I got an error with my instagram credentials, but when I went to update them, the Hash field wouldn't fill itself out when the button (circled below) was clicked (in the past I've done this many times across many versions without any issue)

From latest version (fresh install) to clarify exactly what I mean. image

I tried using cookies from a different account, and I tried on a fresh install and some past versions, and all had the same issue.

I'm not familiar enough with the ins-and-outs of instagram credentials to know how to manually locate my Hash unfortunately, so I haven't been able to try that

AAndyProgram commented 2 years ago

Confirmed 😞

I have a suspicion that this is due to instagram changing something on their end again.

It is.

The best I can do for you right now is just a regular expression: regeneratorRuntime.+?function.+?var h="([\d\w\S]+?)"

  1. Open new tab page
  2. Open dev tools
  3. Go to instagram.com
  4. The dev tools must display the www.instagram.com document
  5. Go to dev tools
  6. Press Ctrl + F
  7. Click .* and paste the regular expression. Then press enter
  8. Click document by document and in the open response press Ctrl + F and paste the regular expression. Search until you find an alphanumeric text of length ~32
AAndyProgram commented 2 years ago

I'll post a new release in a few days. I added automation and cool toast notifications from automation. So unfortunately, SCrawler may not work on windows 7 and 8. What operating system are you using?

TGJ64 commented 2 years ago

I'm on Windows 10 thankfully

AAndyProgram commented 2 years ago

Did you find the hash with regex I posted?

AAndyProgram commented 2 years ago

BTW, did you like SCrawler on this site

TGJ64 commented 2 years ago

Did you find the hash with regex I posted?

I think I did find it following your instructions, I found two different alphanumeric strings while searching through, one of which was the same hash as was still stored in an older version of SCrawler (I assumed my hash had changed but maybe not), but I still get an instagram credentials error using either, so I'm no longer sure what the issue is, since I'm able to update everything else manually just fine. Going to leave it until next version since I'm not needing to use it for a bit anyhow and whatever strange issue I'm having may just end up being resolved with your changes.

AAndyProgram commented 2 years ago

but I still get an instagram credentials error using either

If you have entered valid credentials and are still getting an error, you must post the profile URL and log. Without the profile URL I can't identify the error!

AAndyProgram commented 2 years ago

Fixed. Please update to the latest release.

If you like SCrawler, please like the program on this site: https://alternativeto.net/software/scrawler/about/.

TGJ64 commented 2 years ago

If you have entered valid credentials and are still getting an error, you must post the profile URL and log. Without the profile URL I can't identify the error!

sorry it took me so long to reply to this, I haven't tried using it for a week. The new update properly grabs the Hash but I still don't seem to have resolved the issue with credentials. After it didn't work on either of my two accounts, I made a new instagram account to test it out and a fresh install of SCrawler v2022.6.6.0, then did the following steps for instagram credentials:

I did not add Hash 2 or Saved posts user, as I've never previously needed to and my understanding is they're only needed if I want to save my own "Saved Posts". I also have not installed any of the plugins. None of these have previously prevented me from downloading from instagram (though they always give me errors in the log when I first run).

The new account I tested this with is tgj64_ Here is the log from my test (using emmawatson as the test User), let me know if there's anything I should try:

2022-06-10 06:29:16: [PluginHost.New]
    Could not load file or assembly 'SCrawler.Plugin.LPSG, Version=2022.6.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
2022-06-10 06:29:16: Message: Could not load file or assembly 'SCrawler.Plugin.LPSG, Version=2022.6.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
    HelpLink: 
    StackTrace:    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
       at SCrawler.Plugin.Hosts.PluginHost..ctor(SFile AssemblyFile, XmlFile& _XML, SFile GlobalPath, XMLValue`1& _Temp, XMLValue`1& _Imgs, XMLValue`1& _Vids)
    -----InnerException 1-----

    -----InnerException 2-----
    Message: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
    HelpLink: 
    StackTrace: 
2022-06-10 06:29:16: [PluginHost.New]
    Could not load file or assembly 'SCrawler.Plugin.XVIDEOS, Version=2022.6.6.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
2022-06-10 06:29:16: Message: Could not load file or assembly 'SCrawler.Plugin.XVIDEOS, Version=2022.6.6.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
    HelpLink: 
    StackTrace:    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
       at SCrawler.Plugin.Hosts.PluginHost..ctor(SFile AssemblyFile, XmlFile& _XML, SFile GlobalPath, XMLValue`1& _Temp, XMLValue`1& _Imgs, XMLValue`1& _Vids)
    -----InnerException 1-----

    -----InnerException 2-----
    Message: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
    HelpLink: 
    StackTrace: 
2022-06-10 06:38:51: Instagram - emmawatson: get Instagram user id
    Invalid JSON primitive: for.
2022-06-10 06:38:51: Message: Invalid JSON primitive: for.
    HelpLink: 
    StackTrace:    at PersonalUtilities.Functions.UniversalFunctions.ErrorsDescriber.Execute(ErrorsDescriber e, Exception ex, MMessage _Message, Object OptionalValueReturn)
       at PersonalUtilities.Tools.WebDocuments.JSON.JsonDocument.Parse(String Text, String RootNodeName, ErrorsDescriber e)
       at PersonalUtilities.Tools.WebDocuments.JSON.JsonDocument.Parse(String Text, ErrorsDescriber e)
       at SCrawler.API.Instagram.UserData.GetUserId()
2022-06-10 06:38:51: Instagram hash requested: emmawatson [Timeline]
2022-06-10 06:38:51: Instagram - emmawatson: data downloading error []
    User ID is not detected
    Parameter name: ID
2022-06-10 06:38:51: Message: User ID is not detected
    Parameter name: ID
    HelpLink: 
    StackTrace:    at SCrawler.API.Instagram.UserData.DownloadData(String Cursor, Sections Section, CancellationToken Token)
2022-06-10 06:38:51: Instagram - emmawatson: get Instagram user id
    Invalid JSON primitive: for.
2022-06-10 06:38:51: Message: Invalid JSON primitive: for.
    HelpLink: 
    StackTrace:    at PersonalUtilities.Functions.UniversalFunctions.ErrorsDescriber.Execute(ErrorsDescriber e, Exception ex, MMessage _Message, Object OptionalValueReturn)
       at PersonalUtilities.Tools.WebDocuments.JSON.JsonDocument.Parse(String Text, String RootNodeName, ErrorsDescriber e)
       at PersonalUtilities.Tools.WebDocuments.JSON.JsonDocument.Parse(String Text, ErrorsDescriber e)
       at SCrawler.API.Instagram.UserData.GetUserId()
2022-06-10 06:38:51: Instagram hash requested: emmawatson [Stories]
2022-06-10 06:38:51: Instagram - emmawatson: data downloading error []
    User ID is not detected
    Parameter name: ID
2022-06-10 06:38:51: Message: User ID is not detected
    Parameter name: ID
    HelpLink: 
    StackTrace:    at SCrawler.API.Instagram.UserData.DownloadData(String Cursor, Sections Section, CancellationToken Token)
2022-06-10 06:38:52: Check your Instagram credentials
AAndyProgram commented 2 years ago

I did not add Hash 2 or Saved posts user, as I've never previously needed to and my understanding is they're only needed if I want to save my own "Saved Posts".

You understand right

User ID is not detected Parameter name: ID

This is a known issue. Found it for the first time two days ago. Something has changed on Instagram in cookies. And I don't understand what exactly.

2022-06-10 06:29:16: [PluginHost.New] Could not load file or assembly

Always update all files in the plugin folder or just delete them (if you don't use them).

An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework.

If I understand correctly, you launched SCrawler from network location. If so, you should run SCrawler from a physical drive.

I also suggest you check the NET.Framework version using this PowerShell tool.


Okay. If I understand correctly, you have a problem when you try to download a newly added profile. Unfortunately, as I wrote a few lines ago, something has changed on Instagram. Instagram returns me an error when I try to get the User ID.

Am I right?

If so, then the only way I can help you right now is (this is example):

  1. Open Instagram, Open dev tools
  2. Go to https://www.instagram.com/ricky_martin/
  3. Find the document ?username=ricky_martin
  4. Go to preview tab
  5. Data - Data - User - id

image

You then need to add this ID to the user's XML file and restart SCrawler.

AAndyProgram commented 2 years ago

Fixed. Please update to the latest release.

From now on, Instagram requires Cookies, Hash and authorization headers. Please verify your settings!


And please start writing me answers when I fix your issues. A few words are enough (like "everything is fine now").

AAndyProgram commented 2 years ago

fresh install of SCrawler v2022.6.6.0

BTW, a fresh install doesn't fix anything. SCrawler doesn't store errors or anything that allows it to skip some functions etc. You're just making it harder to work with SCrawler because after a fresh install you'll have to add and download profiles again. If I change some SCrawler settings, I always make the methods compatible with older versions. And I leave them in SCrawler for at least 5 versions. This simplifies the user experience as they don't need to update settings (except when I write it in the release notes). If you need to update your credentials, just open the site settings and change them.

TGJ64 commented 2 years ago

And please start writing me answers when I fix your issues. A few words are enough (like "everything is fine now").

I usually try to! Sometimes I just don't get around to trying the changes for a week or so. The latest version fixed my issues, thanks!

AAndyProgram commented 2 years ago

And thank you. Your issues help me make SCrawler better. As far as I can see, you are one of the most active users of SCrawler. I really appreciate it and I'm very glad that you like my program! 😊

AAndyProgram commented 2 years ago

Instagram has changed something again. But now we have the ability (which we didn't have before) to get a Hash in the same way as Hash 2.

  1. Open browser developer tools
  2. Go to Network
  3. If this tab contain any data, clear it.
  4. Open any profile.
  5. Click Ctrl + F and find the text query_hash=. The alphanumeric value after the equal sign is the required hash. Copy this and paste it into the Hash 2 field on the Instagram settings form.

Curved arrows now don't work (return wrong hash). They will be removed in the next version.

TGJ64 commented 2 years ago

Curved arrows now don't work (return wrong hash). They will be removed in the next version.

Related to this change with the new Hash issues, I'm finding that when I Download All (and also occasionally some other times, I've not nailed down what causes it exactly) the hash field gets automatically re-filled with the wrong hash as well. I'm assuming there may be some points in your code where it tries to refresh the hash automatically but I'm generally having to confirm it's using the proper hash and then select everything and Download Selected or else the hash gets changed again.

AAndyProgram commented 2 years ago

Yes, it is. The problem is in SCrawler. This will be fixed in the next version

AAndyProgram commented 2 years ago

Updated Instagram settings guide: https://github.com/AAndyProgram/SCrawler/wiki/Settings#instagram