<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[עזרה בקוד פייתון]]></title><description><![CDATA[<p dir="auto">אני כותב סקריפט שמוריד פודקאסטים מפיד RSS<br />
הוספתי בסקריפט דילוג על פרקים שכבר הורדו בעבר - כל קישור לפרק נכתב לקובץ לוג ואז לפני כל הורדה של פרק יש בדיקה אם הקישור אליו מופיע בלוג<br />
משום מה החלק הזה לא עובד לי והסקריפט מוריד בכל אופן (הוא אפילו לא נכנס ל if)<br />
הקטע הלא תקין הוא בשורות 36 - 41</p>
<pre><code>#imports required libraries
import feedparser
import requests
import os

#get user inputs
pod_link = input("rss feed link : ")
max_loop = input("The maximum number of podcasts to download : ")

#parsing the rss file
print("parsing the rss file...")
feed = feedparser.parse(pod_link)

#validating the feed
if feed['feed'] == {}:
    raise RuntimeError("Something bad happened")

#initialize the counter
loop = 0

#preparing the log file
pod_list = open("pod_list.lst", 'w')
pod_list.write("list of all podcasts links" + '\n')

#starts working
for entry in feed.entries:
    if loop == int(max_loop):
        break
    else:
        print("downloading podcast number " + str(loop+1))
        link = entry.links[0]
        pod_title = entry.title
        link1 = link["href"]

        #check the log for existing podcasts
        with open("pod_list.lst", 'r') as f:
            content = f.read()
            if link1 in content:
                print("skipping podcast number " + str(loop+1))
                continue
            else:
                pod_list = open("pod_list.lst", 'a')
                pod_list.write(link1 + '\n')
                podcast = requests.get(link1)
                open(pod_title + ".mp3", 'wb').write(podcast.content)
                loop += 1

#closing the log file
pod_list.close()

</code></pre>
]]></description><link>https://tchumim.com/topic/14069/עזרה-בקוד-פייתון</link><generator>RSS for Node</generator><lastBuildDate>Mon, 09 Mar 2026 11:49:52 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/14069.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Oct 2022 11:31:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to עזרה בקוד פייתון on Thu, 13 Oct 2022 20:24:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aaron">@<bdi>aaron</bdi></a> היו בקוד הזה כמה וכמה בעיות, זה הקוד הסופי</p>
<pre><code>#imports required libraries
import feedparser
import requests
import os
 
#get user inputs
pod_link = input("rss feed link : ")
max_loop = input("The maximum number of podcasts to download : ")
 
#parsing the rss file
print("parsing the rss file...")
feed = feedparser.parse(pod_link)
 
#validating the feed
if feed['feed'] == {}:
    raise RuntimeError("Something bad happened")
 
#initialize the counter
loop = 0
 
#preparing the log file
if not os.path.exists("pod_list.lst"):
    f = open("pod_list.lst", 'w')
    f.close()
pod_list = open("pod_list.lst", 'r+')
pod_list.write("new session" + '\n')
content = pod_list.read()
current_pods = []
 
#starts working
for entry in feed.entries:
    link = entry.links[0]
    link1 = link["href"]
    pod_title = entry.title
    if not loop == int(max_loop):
        if link1 in content:
            print("skipping podcast number" + str(loop+1))
            loop += 1
            continue
        else:
            print("downloading podcast number " + str(loop+1))
            podcast = requests.get(link1)
            open(pod_title + ".mp3", 'wb').write(podcast.content)
            current_pods += link1+'\n'
    else:
        break

    loop += 1

with open("pod_list.lst", 'a') as f:
    for line in current_pods:
        f.write(f"{line}")
</code></pre>
]]></description><link>https://tchumim.com/post/145927</link><guid isPermaLink="true">https://tchumim.com/post/145927</guid><dc:creator><![CDATA[אף אחד 3]]></dc:creator><pubDate>Thu, 13 Oct 2022 20:24:51 GMT</pubDate></item><item><title><![CDATA[Reply to עזרה בקוד פייתון on Wed, 12 Oct 2022 16:56:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%90%D7%A3-%D7%90%D7%97%D7%93-3">@<bdi>אף-אחד-3</bdi></a> כתב ב<a href="/post/145907">עזרה בקוד פייתון</a>:</p>
<blockquote>
<p dir="auto">pod_list = open("pod_list.lst", 'w')</p>
</blockquote>
<p dir="auto">אתה פותח את הקובץ כל ריצה במצב כתיבה וכותב לתוכו, זה אומר שהוא נדרס בכל ריצה מחדש.</p>
<p dir="auto">סתם הצעה לשיפור, אין עניין לפתוח את הקובץ מחדש בכל פרק, תקרא את כל המידע בהתחלה.<br />
תכניס את כל הלולאת פור לתוך הבלוק של הפתיחת קובץ</p>
]]></description><link>https://tchumim.com/post/145913</link><guid isPermaLink="true">https://tchumim.com/post/145913</guid><dc:creator><![CDATA[aaron]]></dc:creator><pubDate>Wed, 12 Oct 2022 16:56:07 GMT</pubDate></item></channel></rss>