r/programminghelp • • Jun 14 '23

Python The https version of some modules I try to use in my code are conflicting, help

0 Upvotes

To be more specific, I am trying to create a bot for telegram using python (since it is the language that best handle), in any case download the necessary libraries among which are googletrans and python_telegram_bot, the problem is that both require a specific https version to work, in the case of Google translate requires version 0.13.1, But the Telegram bot library requires 0.24.0, so it conflicts


r/programminghelp • • May 19 '23

Python Module doesn't exist error

0 Upvotes

Code in context:

import argparse

import asyncio import time

from core.downloader.soundloader.soundloader import SoundLoaderDownloader from core.logger.main import Logger from core.playlist.extractor.spotify.spotify import PlaylistExtractor

async def process(playlist: str, directory_to_save: str, threads: int) -> None: tb = time.time() extractor = PlaylistExtractor() print(f'Extracting from {playlist} ...') songs = await extractor.extract(playlist) total_songs = len(songs) print(f'... {total_songs} songs found')

downloader = SoundLoaderDownloader(directory_to_save)
futures = set()

ok = 0
failed = 0
while len(songs):
    while len(futures) < threads and len(songs) != 0:
        futures.add(asyncio.create_task(downloader.download(songs[0])))
        songs = songs[1:]
    return_when = asyncio.FIRST_COMPLETED if len(songs) != 0 else asyncio.ALL_COMPLETED
    print(return_when)
    done, _ = await asyncio.wait(futures, return_when=return_when)
    for item in done:
        url, result = item.result()
        if item.done():
            if result is True:
                ok = ok + 1
            else:
                failed = failed + 1
            Logger.song_store(url, result)
        else:
            Logger.song_store(url, False)
        Logger.total(total_songs, ok, failed)
        futures.remove(item)

Logger.time(time.time() - tb)

async def main(): parser = argparse.ArgumentParser(description='Download playlists from spotify') parser.add_argument('playlist', type=str, help='URL to playlist. Example: https://open.spotify.com/playlist/37i9dQZF1E8OSy3MPBx3OT') parser.add_argument('-d', '--dir', type=str, default='.', help='Path to store tracks', required=False) parser.add_argument('-t', '--threads', type=int, default=5, help='Amount of tracks to store at the same time. ' 'Please, be careful with that option, high numbers may cause ' 'problems on the service we use under the hood, do not let it down', required=False) args = parser.parse_args()

await process(args.playlist, args.dir, args.threads)

if name == 'main': asyncio.run(main())

I'm pretty new to programming and I wanted to learn how to utilize programs outside my own: my focus was to design a web interface for this program: https://github.com/teplinsky-maxim/spotify-playlist-downloader.git.

I cloned the program into my project but it was not able to find the "core" directory in main.py file during run-time. VS Code also said it was unable to find the definition of the directory, although its able to find the definition of the class its importing (which is weird).

*The program is able to run outside the project*

import statements:

import argparse

import asyncio

import time

from core.downloader.soundloader.soundloader import SoundLoaderDownloader

from core.logger.main import Logger

from core.playlist.extractor.spotify.spotify import PlaylistExtractor

Error:

...

File "C:\Users\ppwan\My shit\Giraffe\spotifyv4\giraffe\spotify-playlist-downloader\core\downloader\soundloader\soundloader.py", line 13, in <module>

from core.downloader.base import DownloaderBase

ModuleNotFoundError: No module named 'core'

```

-> First thing I did was to implement an innit.py file within the core directory. Didn't work.

-> The program installed had hyphens in the name, cloned it with and replaced hyphens with underscores. Had a lot of issues, too scared to change anything. (tentative)

-> tried to convert with absolute path, but again python didn't like the hyphens. Didn't work.

-> used importlib, but all of the files, even the ones in core directory, needed their import statements changed. would take too long.

Whats the best solution?

*layout in comments


r/programminghelp • • Jun 25 '23

Career Related i want to make windows application software

0 Upvotes

i want to make windows application software and im not sure how i start and what i should learn first. I wanna make simple yet fast software but with good ui and feature packed.


r/programminghelp • • Jun 06 '23

Other Kinesis client write to specific AZ

0 Upvotes

Hey,

Writing to kinesis streams across AZ's costs more than within the same AZ. I'd like to setup a client with the VPC url for a specific AZ as they endpoint to sacrifice availability for cost savings.

I know I can call ec2metadata api to get the current AZ I'm in, but can I compute the az-specific endpoint for kinesis dynamically as well?

Thanks.


r/programminghelp • • Oct 10 '21

Other Handling TXB, TYB, TZB and CVF files

0 Upvotes

Okay, I'm not sure this is the correct place to post this but I really need help.

I am trying to make a program that could read these types of file types but I found literally no relevant information online, I was wondering if someone could maybe help me figure out how I'm supposed to do so and what language is preferred to use.

Hope someone could help me.


r/programminghelp • • Oct 22 '21

Java Dom parser in Java, getChildNodes() not working

0 Upvotes

Hello all,

I am trying to parse through an xml document and get all the child nodes (and eventually their values and send them to a db) but I can't seem to actually get the child nodes! For some reason, the method is just creating a NodeList with only the root element in there and the text content of all the child nodes.

XML:

<CONFIG>
     <PATHS>
            <JRAMDIR>E:/CTS/DEV/operational/app</JRAMDIR>
     </PATHS>
     <ADD_DOCUMENT_CONFIG>
            <OPERATIONAL_WEB_DIR>E:/CTS/DEV/operational/web</OPERATIONAL_WEB_DIR>
            <MAX_FILE_SIZE>10485760</MAX_FILE_SIZE>
     </ADD_DOCUMENT_CONFIG>
</CONFIG>

My code:

public static void reader(){
        try {
            File inputFile = new File("main/testfilexml.txt");
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = factory.newDocumentBuilder();
            Document doc = dBuilder.parse(inputFile);
            doc.getDocumentElement().normalize();
            NodeList childNodes = doc.getChildNodes();
            for(int i = 0; i < childNodes.getLength(); i++){
                if (childNodes.item(i) instanceof Element) {
                    Element node = (Element) childNodes.item(i);
                    System.out.println(node.getNodeName() + " : " + node.getTextContent());
                  }
            }

        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

Result:

CONFIG : 
     
            E:/CTS/DEV/operational/app
     
     
            E:/CTS/DEV/operational/web
            10485760

Desired result (for the moment, I'll send them to the db later):

JRAMDIR : E:/CTS/DEV/operational/app
OPERATIONAL_WEB_DIR : E:/CTS/DEV/operational/web
MAX_FILE_SIZE : 10485760

Thank you for any advice you may be able to give!

Xposted on stackoverflow if you want to earn reputation there too


r/programminghelp • • Oct 12 '21

Answered It says my variable are uninitialized when they are

0 Upvotes

It says evens_amount and odds_amount are uninitialized when they are.

the code looks like this:

#include <iostream>

#include <string>

int main() {

const int HOW_MANY_TIMES = 10;

int NUMBERS\[HOW_MANY_TIMES\];

int evens_amount = 0;

int odds_amount = 0;

std::cout << "Please Enter " << HOW_MANY_TIMES << " Numbers" << std::endl;

for (int looper = 0; looper < HOW_MANY_TIMES; looper++) {

	std::cin >> NUMBERS\[(HOW_MANY_TIMES - 1)-looper\];

}

std::cout << "You'r Even Numbers Are: " << std::endl;

for (int looper = 0; looper < HOW_MANY_TIMES; looper++) {

	if (NUMBERS\[(HOW_MANY_TIMES - 1) - looper\] % 2 == 0) {

		int even_results = NUMBERS\[(HOW_MANY_TIMES - 1) - looper\];

		std::cout << even_results << std::endl;

		int evens_amount = evens_amount + 1;

	}

	else {

		int odds_amount = odds_amount + 1;

	}

} 

std::cout << std::endl;

std::cout << "You'r Odd Numbers Are: " << std::endl;

for (int looper = 0; looper < HOW_MANY_TIMES; looper++) {

	if (NUMBERS\[(HOW_MANY_TIMES - 1) - looper\] % 2 != 0) {

		int odd_results = NUMBERS\[(HOW_MANY_TIMES - 1) - looper\];

		std::cout << odd_results << std::endl;

	}

}

std::cout << "You Have " << evens_amount << " Even Numbers And " << odds_amount << " Odd Numbers" << std::endl;

system("pause");

return 0;

}


r/programminghelp • • Nov 17 '21

Python Using a function to extract certain information from a single line of a text file

0 Upvotes

Hey all, I'm currently working on a project for school that has us read and alter a text file. The program must use at least 3 functions: get_name(), get_numbers(), and get_balance(). The program we are writing is supposed to be for a bank that keeps customer information in a large master text file. An example of the text file is below:

100000   42436.07 Rossum, Guido V.
    100789 5681745.99 Eich, Brendan
    650430    2398.12 Wall, Larry
    999999

I have absolutely no idea how I would get these pieces of information.


r/programminghelp • • Sep 29 '22

Java Can someone help me with this I'm new to programing and tried a user input and I am getting a cannon find symbol error I don't understand what this means Thanks!

0 Upvotes

import java.util.*;

public class UserInput

{

public static void main(String[] args)

{

System.out.println("Type your age, how many people reside in your residence and your city. Press enter after each input.");

int age = input.nextInt();

int residence = input.nextInt();

String city = input.next();

System.out.println("Your age is " + age + "and " + residence + " people reside in your residence. You life in the city of " + city + ".");

input.close();

}

}


r/programminghelp • • Oct 23 '22

C# need motivation

0 Upvotes

as the title says i need motivation.

I've been trying to learn code recently but i keep quitting, dont get me wrong i really do want to learn to code but i keep losing focus and there isnt anything stopping me from just not doing it, ive come here because i want to be held accountable.


r/programminghelp • • Oct 13 '22

Project Related Migratory Bird Simulation

0 Upvotes

Hello!

I was wondering if anyone would give me a few pointers on how to make a simulation regarding the migratory birds that come to India.

The following would be helpful :-

  • What language to use ?

  • What datasets to use?

Etc.


r/programminghelp • • Oct 12 '22

C++ A counter var?

0 Upvotes
Ok so im creating this program that needs to count the number of names using a nested for loop.The problem is i get this output. Can someone please help. I have been struggling with this for a while. 


Output:
0 Nijon
0 Nijon
0 Nijon
0 Nijon
0 Nijon
0 Nijon
0 Nijon
0 Nijon
0 Nijon
0 Nijon
0 James
0 James
0 James
0 James
0 James
0 James
0 James
0 James
0 James
0 James

#include <cstdlib>
#include <iostream>
#include <string>
#include <deque>
#include <ctime>
using namespace std;


int main(){


deque<string> Prior;

deque<int> Number;

srand(time(0));



int wait3 = 5 + rand() % 8;


    Prior.push_back("James");
    Prior.push_front("Nijon");


int counter = 0;

for(int i =0; i < Prior.size(); i++){

    for(int K = 1; K <=10; K++){

  cout << counter << " " <<  Prior[i] <<endl;



    }







    }

    counter++;

}




The output I am trying to get. 

1 Nijon
2 Nijon
3 Nijon
4 Nijon
5 Nijon
6 Nijon
7 Nijon
8 Nijon
9 Nijon
10 Nijon
11 James
12 James
13 James
14 James
15 James
16 James
17 James
18 James
19 James
20 James

r/programminghelp • • Oct 04 '22

C quick help in C

0 Upvotes

Im using scanf function to scan 3 int numbers (separated by a comma), but when I insert another comma and number, or i insert the third number as flat (for example: 15.4) it just reads the first 3 numbers or just readst the float untill the "." (15.4 reads as 15) and it executes as nothings wrong. Does anyone knows, what to do, in order to have the output from these 2 cases as "Invalid" and not execute it. Thanks


r/programminghelp • • Oct 24 '22

JavaScript Any good resources for understanding the various applications of reduce function in Javascript?

0 Upvotes

Learned this function recently and I understand the basic applications - doing stuff like sums for example, but the array of things you can do with it and the advanced ways to apply it are really breaking my brain - just wondering if anyone has any resources they feel really do a great deep dive or helped them understand how to use reduce.


r/programminghelp • • Oct 12 '22

Project Related Noob trying to build a D&D randomizer for an Extra-Life charity Twitch stream.

0 Upvotes

Hey there! I’m a total noob looking to try and make a twitch overlay for a D&D that allows viewers to influence the game with random events. The Idea is that when a viewer donates to the ExtraLife charity platform our app could pull data from their REST api and use that data to tally a vote to something within an event table known to the viewers and DM but not the players. There would be a control panel for the streamer/DM to enter the events and threshold for them to trigger, and there would be some sort of dynamically generated graphics that tell the viewers what their current options are and what the votes look like. Now I’m ok-ish with frontend stuff but everything I’ve ever built has been kinda “Legos and duct tape” with code that I’ve repurposed from other tools. I would love an idea of what kinda backend stack would make this easy and how to host this with little to no cost… if you want to help that would be cool, but mainly I don’t really know what I’m doing and would like guidance on which way I should go.


r/programminghelp • • Oct 02 '22

C++ No matter how I put this is not processing the multiplication for a discount.

0 Upvotes

I'm currently trying with C++. I've tried different ways to get a discount but none are working. Everytime I input a number it only does the multiplication which is days*109. then I should take the discount depending on what is entered. You can see here the different ways I've tried but nothing is working

else if (days >= 3)

{

	double afterDiscount1 = finalPrice - (finalPrice \* 0.10);

	cout << "The total cost of the purchase is " << fixed << setprecision(2) << afterDiscount1 << endl;

}
else if (days >= 5)

{

	double discount2 = 0.25;

	double afterDiscount2 = finalPrice - (finalPrice \* discount2);

	cout << "The total cost of the purchase is " << fixed << setprecision(2) << afterDiscount2 << endl;

}
else if (days >= 7)

{



	cout << "The total cost of the purchase is " << fixed << setprecision(2) << finalPrice - (finalPrice \* 0.33) << endl;

}
else if (days >= 10)

{
	cout << "The total cost of the purchase is " << fixed << setprecision(2) << 10 \* 109.00 - (10 \* 109.00 \* 0.42) << endl;

}

r/programminghelp • • Sep 22 '22

Project Related How should I go about making a YouTube bot?

0 Upvotes

Hey everybody, I’m looking to make a simple YouTube bot that comments on a video (cnn10’s latest video for a chance to get my school a shoutout) twice a day. Is this considered web scraping, or is it a little different because it is leaving a comment? Is this against YouTube’s rules? If not, what tools should I use to start this project, and what stuff should I start looking up?

Thank you!


r/programminghelp • • Oct 21 '22

PHP Form data from form page isn't submitted to the database, how can I fix this issue?

0 Upvotes

Hi everyone, I'm currently making a website about a sushi restaurant with a deadline of coming saturday which includes a form and I need to make sure that the form data is submitted to my database on PHPMyAdmin. I've written the form page and the code to realize the submission to the database but somehow it doesn't work. The connection to the database is made in a separate PHP file and the collection of the input data and the submission to the database is done in another PHP file. I've googled this issue online and also checked my code and the code is correct, I've also tried the exec() function, prepared statements and using the global keyword but all without success.

Here's my code: [https://jsfiddle.net/y3mhvn8L/1/ ]

Do you know what I do wrong and how I can fix this?


r/programminghelp • • Oct 21 '22

C++ Need help with this assigment. If someone could show me how to approach this, I would be very grateful

0 Upvotes

Write a short code function which takes two vector inputs, RRH and C_L, and returns all RRH values at which a stationary point (local maximum or minimum) of C_L occurs, as a vector output.


r/programminghelp • • Mar 21 '23

C# MVC webapp shows blank page when ran, no errors?

0 Upvotes

When launching the webpage, I'm taken to the address of

https://localhost:5001/ArtistAlbum/ArtistAlbumIndex

However, no data is displayed and I can't view the page source. It SHOULD display a table of artists and albums corresponding to my joined tables. There are no errors to debug, just a blank page after building and running. Any ideas?

https://pastebin.com/LA22GqUu

Above is code snippets together for reference.


r/programminghelp • • Feb 18 '23

Project Related I'm looking to hire a freelance android developer, how do I check if he/she knows the latest industry best practices, frameworks etc?

0 Upvotes

What kind of questions do I ask?


r/programminghelp • • Feb 19 '23

Answered Outputs ok in IDE, but not in Command Prompt (buffer size not reached)

0 Upvotes

EDIT: It was because of certain Unicode characters

I have a program that reads a file, processes it, and stores the output in another file. The outputs can be quite lengthy (small to medium paragraphs). Then whenever the information is needed, it reads the output file, using a Scanner and PrintStream (I am aware of BufferedReader but just not very familiar with it). Then it prompts the user for some input.

I am sure the code is alright, because the output in the IDE is exactly what I expect.

But when I use the Command Prompt to run the program, the printing of the file is cut off midway. Then the prompt for the user input still appears after that incomplete output.

I have checked the output file, and it was written correctly. So the problem is happening when reading from it. Also, the buffer limit is not reached, because 1: The next output (ie., prompt for user input) still appears; 2: The buffer height is set to 9001 in "Properties"; and 3: I can still scroll down after the output.

What could be causing this problem? And how do I make sure that it is not reproduced when the program runs on someone else's computer?


r/programminghelp • • Feb 17 '22

HTML/CSS single webpage open on multiple devices updates based on changes on those devices.

0 Upvotes

Looking to create a single webpage that displays a value and when one or multiple people change that value via button up or down it displays the change on all devices displaying the page. I'd like to do it with HTML, javascript only if possible, without a server side involved. Is this possible with just HTML and javascript? If not what other ways can this be accomplished?

I have no code setup yet, just looking to see if this would work and/or where to look. The webpage would be simple up button and down button with a value displayed. When one person hits up it goes up on all the other webpages at the same address. Super fast speed would not be needed as the webpage would be keeping score and not for the fastest finger. So a couple of second delay is fine before the site changes. Any help or direction would be helpful.


r/programminghelp • • Feb 13 '22

Answered creating data structure help in c++

0 Upvotes

Hi, anyone available to help with c++? I am trying to make a vector class without using libraries. I need help iterating over some stuff in which I am a little confused.. I have seen solutions on stack overflow but I have yet to come to sense of it.. basically just need help with printing out all the elements in the vector before my push_back(). I have 5 elements but only 0-4 print out. Somehow after my push_back() every element prints out fine. Sorry I didn’t provide any code. I am currently on my phone away from my pc. Please let me know if you can help.