Crissium / variety-daily-verse

Display Bible Gateway's verse of the day on your Linux desktop
GNU General Public License v3.0
5 stars 4 forks source link

cannot get verses #1

Open kanglinyao opened 1 year ago

kanglinyao commented 1 year ago

It seems the script stopped working.

Crissium commented 1 year ago

Well, I have observed that during certain times of the day, Bible Gateway's JSON API would 'go down', mostly in evening (GMT+8). Now (8 a.m. GMT+8) it works perfectly on my machine.

Let's see if running the following in the python console works.

import requests
requests.get('https://www.biblegateway.com/votd/get/?format=json').content

Does it print something likeb'{"votd":{"text":"“Let the peace of Christ rule in your hearts, since as members of one body you were called to peace. And be thankful.”","content":"Let the peace of Christ rule in your hearts, since as members of one body you were called to peace. And be thankful.","display_ref":"Colossians 3:15","reference":"Colossians 3:15","permalink":"https:\\/\\/www.biblegateway.com\\/passage\\/?search=Colossians%203:15&version=NIV","copyright":" ","copyrightlink":"https:\\/\\/www.biblegateway.com\\/versions\\/index.php?action=getVersionInfo&vid=31&lang=2","audiolink":"https:\\/\\/www.biblegateway.com\\/audio\\/mclean\\/niv\\/Col.3.15","day":"22","month":"11","year":"2022","version":"New International Version","version_id":"NIV","merchandising":""}}'?

kanglinyao commented 1 year ago

Yes, it printed the verse in console, but the plugin still gets no verses for variety.

This is what the verse.py contains: response = json.loads(requests.get('https://www.biblegateway.com/votd/get/?format=json&version=' + version).content) return [{'quote': html.parser.HTMLParser().unescape(response['votd']['text']), 'author': response['votd']['display_ref'], 'sourceName': None

I notice the forma=json&version, which is different from the

import requests
requests.get('https://www.biblegateway.com/votd/get/?format=json').content
Crissium commented 1 year ago

Then I believe maybe it's a problem with variety. I cannot reproduce the bug and I don't know where variety's logs are stored. Perhaps you may open an issue at variety?

I notice the forma=json&version, which is different from the

Without the version query parameter, Bible Gateway defaults to NIV. For instance, if you specify the version as RCU17SS:

>>> requests.get('https://www.biblegateway.com/votd/get/?format=json&version=RCU17SS').content
b'{"votd":{"text":"&ldquo;[&#22522;&#30563;&#37324;&#30340;&#20016;&#30427;]  &#26082;&#28982;&#20320;&#20204;&#25509;&#21463;&#20102;&#20027;&#22522;&#30563;&#32822;&#31267;&#65292;&#23601;&#35201;&#38752;&#30528;&#20182;&#32780;&#29983;&#27963;&#65292;  &#29031;&#30528;&#20320;&#20204;&#25152;&#39046;&#21463;&#30340;&#25945;&#23548;&#65292;&#22312;&#20182;&#37324;&#38754;&#29983;&#26681;&#24314;&#36896;&#65292;&#20449;&#24515;&#22362;&#22266;&#65292;&#20805;&#28385;&#30528;&#24863;&#35874;&#30340;&#24515;&#12290;&rdquo;","content":"<h3>&#22522;&#30563;&#37324;&#30340;&#20016;&#30427;<\\/h3> &#26082;&#28982;&#20320;&#20204;&#25509;&#21463;&#20102;&#20027;&#22522;&#30563;&#32822;&#31267;&#65292;&#23601;&#35201;&#38752;&#30528;&#20182;&#32780;&#29983;&#27963;&#65292; &#29031;&#30528;&#20320;&#20204;&#25152;&#39046;&#21463;&#30340;&#25945;&#23548;&#65292;&#22312;&#20182;&#37324;&#38754;&#29983;&#26681;&#24314;&#36896;&#65292;&#20449;&#24515;&#22362;&#22266;&#65292;&#20805;&#28385;&#30528;&#24863;&#35874;&#30340;&#24515;&#12290;","display_ref":"\\u6b4c\\u7f57\\u897f\\u4e66 2:6-7","reference":"Colossians 2:6-7","permalink":"https:\\/\\/www.biblegateway.com\\/passage\\/?search=Colossians%202:6-7&amp;version=RCU17SS","copyright":" ","copyrightlink":"https:\\/\\/www.biblegateway.com\\/versions\\/index.php?action=getVersionInfo&amp;vid=258&amp;lang=2","audiolink":"","day":"24","month":"11","year":"2022","version":"Revised Chinese Union Version (Simplified Script) Shen Edition","version_id":"RCU17SS","merchandising":""}}'
Crissium commented 1 year ago

Well, the same bug now occurs on my machine. And other variety plugins (the built-in quotes plugins) work perfectly. So I think there's indeed something wrong with my script. But I'm very busy now and hope that I can look into the problem after 14 Jan. Sorry for the inconvenience.

linchen2chris commented 1 year ago

@kanglinyao you could check your python if it's 3.9, after downgrade to 3.8 will fix it.

Crissium commented 1 year ago

@kanglinyao Hello, today the script completely broke down on my machine too. And after digging through the source code of variety, I found that it set an upper limit on the length of the quote. So when I set quotes_max_length to 4096 in ~/.config/variety/variety.conf, it works again.

I will include a note about this in the README shortly.