Sponsored Links:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
5. Lists, Loops & Regex
#1
This guide we go through how to manipulate and create lists, use loop functions and even briefly go into some basic regex functions.

Please only use this thread for support with any of the subjects covered in this particular episode, thank you.




WANT EARLY DEVELOPMENT RELEASE ACCESS?
All users who've helped out with a donation can now gain early access to the
latest test versions of add-ons, often weeks or months ahead of the public stable releases.

[Image: 11i3ihd.jpg]
  Reply
Sponsored Links:
#2
whufclee, another great tutorial. I noticed that you didn't go into detail on the Open_URL function. Is it worth researching in detail?

FYI, I couldn't find an option to delete my post, so I just updated it.

Update:
Disregard my comment above, it is discussed at the end of the video.
  Reply
#3
Hi Lee, firstly a massive thank you for your time so far making this brilliant coding tutorial, awesome stuff.

I have been following the videos and I seem to have gone wrong somewhere in the code where you open the url, I just wondered if you could post the actual default.py on here so I could easily check where I've gone wrong.


Only in the videos you un-comment out that entire section and I'm finding it quite hard to copy all the code as the req.add_header line is quite long and I can't see the end of the line to copy it correctly.

I'm assuming that's where I've gone wrong anyway.
  Reply
#4
I got it all working in the end, I had to keep checking the Kodi log to find out where I'd gone wrong.
Basically syntax errors, I missed a letter p out of one of the response lines and I'd missed a colon out of one of the lines also.


Sent from my iPad using Tapatalk
  Reply
#5
(08-02-2016, 02:29 PM)Y05h1mura Wrote: I got it all working in the end, I had to keep checking the Kodi log to find out where I'd gone wrong.
Basically syntax errors, I missed a letter p out of one of the response lines and I'd missed a colon out of one of the lines also.


Sent from my iPad using Tapatalk
Excellent stuff. Glad you were able to figure it out on your own. Makes us all better coders being able to spot our mistakes in the log.

Sent from my SM-N910F using Tapatalk
[Image: nansig_arb.png]
  Reply
#6
It's early days for me, but I've wanted to learn for ages. I've managed to store the list where I host my own personal stuff I've been working on and get all of the 2016 MotoGp replays working from it.
I just need to figure out how to make the folders work with online lists now and I can then create a few more sections.
Chuffed so far, massive kudos to Lee for taking time to make the tutorials.


Sent from my iPad using Tapatalk
  Reply
#7
Thanks for the kind comments it's things like that which make it all worthwhile, glad it's helping.

sorry for the slow reply, got some very urgent stuff on at the moment I need to deal with but just found a spare 10mins to check forum for first time in a few days.

Sent from my A0001 using Tapatalk
WANT EARLY DEVELOPMENT RELEASE ACCESS?
All users who've helped out with a donation can now gain early access to the
latest test versions of add-ons, often weeks or months ahead of the public stable releases.

[Image: 11i3ihd.jpg]
  Reply
#8
Hi Lee, great tutorials. I'm at 31:31 in the video and I'm getting and error. I Know I'm probably missing something obvious but I think I'm having a brainfart moment.  I was trying to upload log via community portal but kept getting addon error. So the best I can do is copy and paste what it says:

ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                            - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                           Error Type: <type 'exceptions.TypeError'>
                                           Error Contents: argument 1 must be string, not tuple
                                           Traceback (most recent call last):
                                             File "C:\Users\user\AppData\Roaming\Kodi\addons\plugin.video.test\default.py", line 40, in <module>
                                               xbmc.log(item)
                                           TypeError: argument 1 must be string, not tuple
                                           -->End of Python script error report<--

This is the current code I have:

Code:
content = read_file(regex1)
xbmc.log('#### CONTENTS: %s' % content)
matches = re.compile('name="(.+?)"\npath="(.+?)"\nthumb="(.+?)"\nfanart="(.+?)"').findall(content)
for item in matches:
xbmc.log(item)
  Reply
#9
(08-07-2016, 10:46 PM)DaveIsHere Wrote: Hi Lee, great tutorials. I'm at 31:31 in the video and I'm getting and error. I Know I'm probably missing something obvious but I think I'm having a brainfart moment.  I was trying to upload log via community portal but kept getting addon error. So the best I can do is copy and paste what it says:

ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                            - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                           Error Type: <type 'exceptions.TypeError'>
                                           Error Contents: argument 1 must be string, not tuple
                                           Traceback (most recent call last):
                                             File "C:\Users\user\AppData\Roaming\Kodi\addons\plugin.video.test\default.py", line 40, in <module>
                                               xbmc.log(item)
                                           TypeError: argument 1 must be string, not tuple
                                           -->End of Python script error report<--

This is the current code I have:

Code:
content = read_file(regex1)
xbmc.log('#### CONTENTS: %s' % content)
matches = re.compile('name="(.+?)"\npath="(.+?)"\nthumb="(.+?)"\nfanart="(.+?)"').findall(content)
for item in matches:
xbmc.log(item)
Hi Dave. It saying you need to change Arguement 1 to a String. Are you able to share your default.py? (Dont copy and paste it in here though)

Log mentions line 40

Sent from my SM-N910F using Tapatalk
[Image: nansig_arb.png]
  Reply
#10
(08-07-2016, 10:55 PM)andrewrb Wrote:
(08-07-2016, 10:46 PM)DaveIsHere Wrote: Hi Lee, great tutorials. I'm at 31:31 in the video and I'm getting and error. I Know I'm probably missing something obvious but I think I'm having a brainfart moment.  I was trying to upload log via community portal but kept getting addon error. So the best I can do is copy and paste what it says:

ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                            - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                           Error Type: <type 'exceptions.TypeError'>
                                           Error Contents: argument 1 must be string, not tuple
                                           Traceback (most recent call last):
                                             File "C:\Users\user\AppData\Roaming\Kodi\addons\plugin.video.test\default.py", line 40, in <module>
                                               xbmc.log(item)
                                           TypeError: argument 1 must be string, not tuple
                                           -->End of Python script error report<--

This is the current code I have:

Code:
content = read_file(regex1)
xbmc.log('#### CONTENTS: %s' % content)
matches = re.compile('name="(.+?)"\npath="(.+?)"\nthumb="(.+?)"\nfanart="(.+?)"').findall(content)
for item in matches:
xbmc.log(item)
Hi Dave. It saying you need to change Arguement 1 to a String. Are you able to share your default.py? (Dont copy and paste it in here though)

Log mentions line 40

Sent from my SM-N910F using Tapatalk

[Image: 55o6pt.jpg]
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)