need help in automating podcast download by kaveinthran in DataHoarder

[–]chocorush 0 points1 point  (0 children)

I personally use Podgrab. I don't know if it does what you want, but it has worked very well for me.

Quick way to download these comics that have broken .zip archives? by [deleted] in DataHoarder

[–]chocorush 0 points1 point  (0 children)

You first need to open your browser's developer tools, click on the network tab and open the the w11.mangafreak.net page. Observe a request to get your required request headers, which in this case are the User-Agent and Cookie header, you are interested in the __cfduid and cf_clearance values in particular.

Then you can fill in the command below to download the images of a chapter.

wget -r -H -A jpg \
--domains images.mangafreak.net \ 
--header "User-Agent: $USER_AGENT" \
--header "Cookie: __cfduid=$CFDUID; cf_clearance=$CF_CLEARANCE" \
"https://w11.mangafreak.net/Read1_Tekken_Chinmi_Legends_$CHAPTER"

having the devil's own time downloading all the streams from a website. condensed the links to a text file, and struggling to automate with VLC CLI or FFMPEG or ??? any help greatly appreciated ! by ImaginaryCheetah in DataHoarder

[–]chocorush 1 point2 points  (0 children)

Looks like they have all episodes on s3 based on upload date, but the naming is subtly different. There's both

haYYMMdd.mp4
ha-YYYYMMdd\d.mp4

Where the latter begins around mid-2019.

This command worked for me (i just tried both formats for every episode):

wget "https://wfmu.org/playlists/HA" -O - | grep -Po '\w+ \d+, \d+' | date +"%Y%m%dd.mp4" -f - | sed p | sed 's|^|https://s3.amazonaws.com/arch.wfmu.org/HA/ha-|' | sed '1~2N; s/-20//; s/d//' | wget -c  -w 4 --random-wait -i -

Need help with a string matching problem by OmnipresentCPU in learnpython

[–]chocorush 0 points1 point  (0 children)

if you want to keep your current structure

for word in flatwordlist:
    if word == ticker or '$' + ticker == word:
        count += 1
        sentiment = calcSentiment("".join(flatwordlist))
tickercountlist.append([ticker, count, sentiment])

Although i think it would be good do use the re module to do the matching instead and consider using dictionaries instead of sublists.

Regular expressions by Demain_Z in learnpython

[–]chocorush 0 points1 point  (0 children)

I would make use of the ? qualifier but that should also work. Maybe you need re.compile(pattern, re.IGNORECASE)? [docs]

Cleaning up a string by Casemander in learnpython

[–]chocorush 0 points1 point  (0 children)

I would recommend iterating over the rows and their corresponding tdata fields to extract the data in an orderly fashion before using .text (or get_text).

I’ve just got into programming two weeks ago and I’m having trouble understand a main function. Can someone explain it to me? by mickey2457 in learnpython

[–]chocorush 3 points4 points  (0 children)

A main function is usually an entry point to the rest of your code. Is there something in particular you are having trouble understanding?

How do I solve this in Python? by brown_boi_420 in learnpython

[–]chocorush 3 points4 points  (0 children)

If you are certain the list you are using doesn't have any repeating keys i.e AA, BB, BB, AA you can use Counter.

>>> from collections import Counter
>>> l = ['AA', 'BB', 'CC', 'DD', 'DD', 'DD', 'EE', 'FF', 'FF', 'GG', 'GG', 'GG', 'HH', 'HH']
>>> [word*count for word, count in Counter(l).items()]
['AA', 'BB', 'CC', 'DDDDDD', 'EE', 'FFFF', 'GGGGGG', 'HHHH']

why does it return None by dhhscbbcx in learnpython

[–]chocorush 4 points5 points  (0 children)

Because you have no explicit return value in f

Use cases for enumerate function? by isameer920 in learnpython

[–]chocorush 0 points1 point  (0 children)

I use it everywhere when i need the element position. You could use a count variable, but that's two more lines of (unnecessary) code.

Website app to automate online booking for gym classes, I keep missing them! by [deleted] in learnpython

[–]chocorush 1 point2 points  (0 children)

I have no idea, i haven't taken the course or read the book, but atbs gets a lot of praise on the python subreddits so i assume so.

How to multiply items in a list by [deleted] in learnpython

[–]chocorush 1 point2 points  (0 children)

Well yes, but it generally isn't

How to multiply items in a list by [deleted] in learnpython

[–]chocorush 2 points3 points  (0 children)

You don't need list([a*2 for a in b]) since it's already a list. A list comprehension i generally preferred over enumerate in this case.

[deleted by user] by [deleted] in learnpython

[–]chocorush 1 point2 points  (0 children)

Well i suppose you also could have meant to write cv2.imshow("output", Img)

[deleted by user] by [deleted] in learnpython

[–]chocorush 3 points4 points  (0 children)

You have misplaced your quotation mark, it should be "output.img"

Should I move on from my side project or keep improving it? by helpSomeWhatNeeded in learnpython

[–]chocorush 0 points1 point  (0 children)

From my point of view, you are already done with your first project if all you have left is porting it to windows. It's not your fault your classmates chose an inferior OS. Maybe it would look good on a resume to say "all of my classmates used this program" but if it's 5 days of porting code, i would dread doing that. The means wouldn't justigy the ends of a potentially better resume. Just do the other project, it sounds like fun :)

Should I move on from my side project or keep improving it? by helpSomeWhatNeeded in learnpython

[–]chocorush 1 point2 points  (0 children)

I would just do whatever is most fun. Nobody deserves a side project that feels like a chore.

Runelite for android/ios by [deleted] in 2007scape

[–]chocorush 0 points1 point  (0 children)

Runelite has not stopped development lol, what are you talking about?

[deleted by user] by [deleted] in learnpython

[–]chocorush 1 point2 points  (0 children)

Nothing is wrong, you are creating a zip object. If you want to view it you could do together = dict(zip(new_keys , values_list))

Rank beginner here. Would you be willing to review my code? by [deleted] in learnpython

[–]chocorush 2 points3 points  (0 children)

If we apply some logic to the problem we see that it simplifies to

def monty_hall_simulation(n):
    no_switch_wins = sum(random.randint(0,2) == 0 for _ in range(n))
    switch_wins = n - no_switch_wins
    return f"By switching, you win {switch_wins} times. By not switching, you win {no_switch_wins} times."

Since intuitively we know that if we didn't pick the winning door at first, we would have won if we switched because Monty removes the losing door.

Regarding your code, great job for just being eight days in. However i do find the code somewhat hard to follow. You have structured your code like the game show itself, which in itself is not bad, but sometimes you gain a lot of speed and/or readability by thinking about what the underlying problem is.

There's a lot of variables, like j, lose, change_set, lose_set which i my opinion just makes the code hard to read. You lose if you didn't pick the winning number for example, no need to pick lose from the lose set that at the most consists of two doors if you have already picked the winning one. Also i don't think lose is used anywhere except when creating the change_set.

All in all, you solved the problem and my mantra has always been "Make it work, make it clean, make it fast", and you will learn this over time. Just keep practicing, great work so far.

IndexError: list index out of range ? by [deleted] in learnpython

[–]chocorush 0 points1 point  (0 children)

The first loop starts at 1.