Help with Text Encoding and URLs?

Any trouble you encounter with the Pedias, here's the place to ask for help.
Post Reply
User avatar
sitenoise
Addicted to Bruji
Addicted to Bruji
Posts: 230
Joined: Fri Mar 21, 2008 12:42 pm
Contact:

Help with Text Encoding and URLs?

Post by sitenoise »

This is probably me and my settings but ...

I have a custom field rigged up to search wikipedia:
<!--IFcustom1<div class="field"><div class="title">[translate:custom1]:</div>
<div class="text"><ahref="http://en.wikipedia.org/wiki/Special:Search?search=[key:title]">[key:custom1]</a>
</div></div>ENDcustom1-->

When the title happens to be more than one word it flies over to Wikipedia thusly, for example: The%20Host and the search results suck.

That's bummer #1 if anyone can help out.

Bummer #2 is if wikipedia has (I guess they are called) high ascii characters in it's URL it won't drag to the Info Window successfully.

For example, any title that must be distinguished as a film because there is also a book or some other such thing with the same title, like Audition, it shows up at Wikipedia as http://en.wikipedia.org/wiki/Audition_%28film%29 from the disambiguation page.

It wants to be: http://en.wikipedia.org/wiki/Audition_(1999_film)

Here's what's weird, if you copy one of the 'bad' URLs, like http://en.wikipedia.org/wiki/Audition_%28film%29 from the location field of your browser (or from the "copy link location" contextual menu), quit the browser and reopen it, and paste that 'bad' URL into the location field and hit return it will go to the right page. (As you may have noticed, that link is also accurately clickable from here)

But when you drag the bad URL into dvdPedia (via the Favicon), or copy/paste it to the links TAB and then click it from dvdpedia it throws up this:

Code: Select all

http://en.wikipedia.org/wiki/Audition_%25281999_film%2529
and Wikipedia says:
Bad title
The requested page title is invalid. It may be empty, contain unsupported characters, or include a non-local or incorrectly linked interwiki prefix.
Am I just trying to do things that dvdpedia isn't intended to do, or is it that I have my text encoding settings wrong, or is dvdpedia parsing something strangely?

Any insight will be appreciated.
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: Help with Text Encoding and URLs?

Post by Conor »

You are right that DVDpedia should take into account the percent escapes when a link is created. Download the program again and for new links that you create the percent escape will be translated, so that when you drag http://en.wikipedia.org/wiki/Audition_%28film%29 you will get http://en.wikipedia.org/wiki/Audition_(film) as a link in the program.
User avatar
sitenoise
Addicted to Bruji
Addicted to Bruji
Posts: 230
Joined: Fri Mar 21, 2008 12:42 pm
Contact:

Re: Help with Text Encoding and URLs?

Post by sitenoise »

Conor, I am stunned by your responses to my posts. In this day and age, responses are rare, but "fixes" to quirks are a whole order of magnitude rare-er. :o

In light of that, I am embarrassed to inquire if there is a solution to Bummer #1 above, that is, hijacking those escape characters on the way out.

Maybe there is just a better way to do what I am trying to do with:

<ahref="http://en.wikipedia.org/wiki/Special:Search?search=[key:title]">[key:custom1]

Perhaps you can tell I am flirting around in territory that's a little over my head. But let me tell you a little about what I think I am shooting for.

Is there support somehow for javascript in these templates? (I think that's my question)

I am an information junkie and I use a ton of Bookmarklets in my browsing.
http://bookmarklets.com/
It's amazing how much faster it is to search with Bookmarklets than to go to a home page of one of these huge database sites, wait for all the junk to download, begin a search, and then wait for all the junk to download again only to find there is no entry for what you are looking for.

<rant>It's a shame that some sites like http://www.allmovie.com/ use asp or php or something for searching that doesn't allow me to Bookmarklet them, especially when they are one of the sloooooowest sites to load. I simply don't go there much.</rant>

So in my dreams (:)), if I could tweak a Info View Template to have a column of clickable Bookmarklets to search a dozen or so sites for the title in question (OR, in heaven, any highlighted text on the page!!) my life would be complete and I could pass on from this mortal coil.

Am I dreaming?
User avatar
sitenoise
Addicted to Bruji
Addicted to Bruji
Posts: 230
Joined: Fri Mar 21, 2008 12:42 pm
Contact:

Re: Help with Text Encoding and URLs?

Post by sitenoise »

OK we can probably skip all that stuff I just posted. I think all I need to know, in order to get close to what I want, is to figure out why, or how to compensate for, why dvdpedia throws up, for example,
The%2520Usual%2520Suspects instead of just
The%20Usual%20Suspects

Code: Select all

<!--IFcustom4<div class="field"><div class="title">[translate:custom4]:</div><div class="text"><a href="http://www.mrqe.com/lookup?[key:title]">[key:custom4]</a></div></div>ENDcustom4-->
You'll probably get a laugh out of this, but I looked at the Bookmarklet javascript for the MRQE:

Code: Select all

javascript:Qr=document.getSelection();if(!Qr)%7Bvoid(Qr=prompt('Keywords...',''))%7D;if(Qr)location.href='http://www.mrqe.com/lookup?'+escape(Qr)
and tried adding +escape(Qr) after [key:title]:

Code: Select all

<!--IFcustom4<div class="field"><div class="title">[translate:custom4]:</div><div class="text"><a href="http://www.mrqe.com/lookup?[key:title]+escape(Qr)">[key:custom4]</a></div></div>ENDcustom4-->
... thinking that these bookmarklets somehow provide escape routes (ya see, you brought up that word escape, so I'm obsessing.)

:lol:
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: Help with Text Encoding and URLs?

Post by Conor »

What is happening is that DVDpedia is doing the right thing and escaping the escape character that should have been encoded.

Code: Select all

%25 = %
What you can do to fix all the old link entries is do a massive find and replace of the links, to do that your going to need the terminal.
You can look at this post for more information. The steps are:
  • 1. Quit DVDpedia
    2. Backup your database file by duplicating ~/Library/Application Support/DVDpedia/Database.pediadata
    3. Open Terminal program
    4. Enter each of these lines followed by a return:

    Code: Select all

    sqlite3 ~/Library/Application\ Support/DVDpedia/Database.pediadata
    update ZLINK Set ZURL = replace(ZURL, '%20', ' ');
    update ZLINK Set ZURL = replace(ZURL, '%28 , '(');
    update ZLINK Set ZURL = replace(ZURL, '%29 , ')');
    .exit
    5. Done.
That should update your links to be properly encoded, I added the update for the common % escapes you might have, if you have others you can add extra update ZLINK commands.

With the Bookmarklets you are creating on the fly leave the links as they are and DVDpedia will turn a space into %20. It will encode all the characters that need encoding before passing the URL to your browser (this is what is happening to the %). However depending on the search sites you might need to replace the space with a plus sign. You could use a javascript like the one you have for that.
User avatar
sitenoise
Addicted to Bruji
Addicted to Bruji
Posts: 230
Joined: Fri Mar 21, 2008 12:42 pm
Contact:

Re: Help with Text Encoding and URLs?

Post by sitenoise »

I don't think I'm following and/or I don't think I described my issue clearly.

First of all, I don't have any old links that need updating as far as I know. Before yesterday if I had dragged a link to dvdpedia, I would test it and if it didn't work I fixed it. Now you made it so they just work, how 'mac' of you.

Setting aside bookmarklets and javascript for a moment, I'm just creating a custom field that contains a search URL:

Code: Select all

 <!--IFcustom4<div class="field"><div class="title">[translate:custom4]:</div><div class="text"><a href="http://www.mrqe.com/lookup?[key:title]">[key:custom4]</a></div></div>ENDcustom4-->
and the result from that, for a dvdpedia title that contains spaces, is The%2520Usual%2520Suspects instead of just The%20Usual%20Suspects when it arrives in my browser. It appears that most websites can handle the latter but not the former. (MRQE is odd in that it says 'no results found'' but has the properly escaped title, in this case, The Usual Suspects, entered into it's search field. However, the location field has http://www.mrqe.com/lookup?The%2520Usual%2520Suspects)

(Actually, what's kind of doubly weird, is that MRQE seems to refuse to load some of the things thrown at it but not others. For example, it seems to not want to load The Usual Suspects at all ... click the above link ..., but will load a no search results page for Five Across the Eyes http://www.mrqe.com/lookup?Five%2520Acr ... e%2520Eyes. 'splain that! :))

As for bookmarklets and javascript, are you saying that in theory this code should work if contained in a custom field?

Code: Select all

javascript:Qr=document.getSelection();if(!Qr)%7Bvoid(Qr=prompt('Keywords...',''))%7D;if(Qr)location.href='http://www.mrqe.com/lookup?'+escape(Qr)
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: Help with Text Encoding and URLs?

Post by Conor »

Say no more download the program again and it shall be fixed. I am sure you have your reasons for having the link inside the custom 4 field, it's a way to quickly enable or disable the link by adding a value to custom4. But if you want to have the link for all movies you can add it by itself (you could even have a little box of potential links that you find useful).

Code: Select all

<div class="text"><a href="http://www.mrqe.com/lookup?[key:title]">MRQE</a></div>
User avatar
sitenoise
Addicted to Bruji
Addicted to Bruji
Posts: 230
Joined: Fri Mar 21, 2008 12:42 pm
Contact:

Re: Help with Text Encoding and URLs?

Post by sitenoise »

Doh!

I told you I was playing in the deep end here! LMAO!!!

I guess I thought being in a field was the only way to call something using the 'keys'. [key:title] ... or actually, it's pretty clear I wasn't doing a lot of thinking. :)

This is a much better solution. Thanks, Conor, sorry for wasting your time.

phil
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: Help with Text Encoding and URLs?

Post by Conor »

I am glad to have been able to help.
Jonas
Addicted to Bruji
Addicted to Bruji
Posts: 28
Joined: Fri Jan 04, 2008 11:58 am
Location: Sweden

Re: Help with Text Encoding and URLs?

Post by Jonas »

I also want to thank you for fixing this.

I have added the code: <a href="http://www.imdb.com/find?s=nm&q=[credit:name]"> ... </a> to the credits part and <a href="http://www.imdb.com/find?s=nm&q=[key:director]"> ... </a> to the director part of the html code for the Info view.
This way I just have to click on the name of the person in the Info view to get to that persons imdb-page.

Before it have only worked for me if the links were opened directly inside of dvdpedia, but not if they were opened in Safari (by checking "Open links in external web brower" in the preferences).

Now they work there too!

So thanks for solving this problem.

/Jonas
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: Help with Text Encoding and URLs?

Post by Conor »

Being a fan of the cast you should check out the mug shot collection for download at DougWeb and add a link to the image in your info template.
Post Reply